Skip to content

Diagnostics: inline-record mutability coercion gives no reason, and throw in finally warns about unreachable code #9185

Done

Description

@cristianoc

Found by differential semantic drift analysis from b123b7c3 to c10223e8.

What is broken

  • Coercion into an inline record with a mutable field gives no reason (#9086). The coercion is now rejected, correctly:

    type v1 = A({x: float})
    type v2 = A({mutable x: float})
    let a: v1 = A({x: 0.})
    let b = (a :> v2)

    The error is only Type v1 is not a subtype of v2. For a field of a plain record type ({r: r1} into {r: r2}) the error explains: "The field x is mutable in record r2, but not in record r1. A coercion can't make a field writable."

  • throw in finally gives warning 21 (#8931):

    exception B
    let k = () => try { 1 } finally { throw(B) }

    Warning 21: "This statement does not continue execution; following code is unreachable." No code follows the throw; the generated JavaScript is correct. The finally block is typed as a statement (typecore.ml L2920-L2922), and a non-returning statement triggers this warning.

Possible cause (speculation only)

The inline-record path reports the subtype failure before reaching the field comparison that produces the explanation for plain records.

🤖 Generated with Claude Code

Activity

  1. added theissue type on Nov 3, 2026
  2. cknitt commented on Dec 3, 2026

    @cknitt
    Member

    Both items are fixed: #9205 explains the inline-record coercion ("The field x is mutable in record v2.A, but not in record v1.A"), and #9204 stops warning 21 for throw in finally.

    Checked by Claude on master 0a686a9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions