Skip to content

Coercion hint: suggestion that doesn't compile after a parenthesized operand, and the hint names the expanded type #9105

Closed

Description

@cristianoc

Found by a bug hunt over the 16 commits from eb087382 to cd641cbc.

A hint that doesn't compile.

type a = {x: int, y: int}
type b = {x: int}
let v: a = {x: 1, y: 2}
let w: b = v->(r => r)

The error is reported at 4:12-21, which leaves out the final ). The hint suggests v->(r => r :> b), and applying it fails with "Type 'a => 'a is not a subtype of b". A suggestion that compiles is (v->(r => r) :> b). The rewrite is built from Parser.extract_text_at_loc loc, so it inherits the truncated location.

The hint names the expanded type.

let f = (x: Generator.t<'a, unit, unit>): Iterable.t<'a> => x

The message says the expected type is Iterable.t<'a> (defined as iterable<'a>), but the hint suggests (x :> iterable<'a>). That compiles, but it doesn't name the type the message shows. The target comes from the expanded element of the trace pair (error_message_utils.ml#L774-L779).

Both reproduce at b123b7c3. Related: #9037.

🤖 Generated with Claude Code

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