Skip to content

Source location gets lost when a type mismatch happens on computation expression #19550

@zvmsbackend

Description

@zvmsbackend

When a type constraint mismatch error happens on a computation expression under certain circumstances, type checker reports "unknown(1, 1)" instead of the desired source location.

Repro steps

Define a computation builder with a Zero method, and apply it in a pipeline with wrong arguments:

type FooBuilder() =
  member _.Zero() = fun x -> x + 42

let foo = FooBuilder()

"" |> foo {} |> printfn "%d"

The compiler reports .../unknown(1, 1) regardless of where the mismatch actually happens. LSP diagnostic get lost as well:

Image

This applies to other operations beyond forward pipe |>.

Expected behavior

The compiler should be able to report correct source location.

Actual behavior

It does not.

Known workarounds

No.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-Diagnosticsmistakes and possible improvements to diagnosticsBug

    Type

    No fields configured for Bug.

    Projects

    Status

    New

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions