dotnet / dotnet/fsharp

Invalid error range for special cases of NoEquality types

Open
#15,518 0 comments 0 reactions 0 assignees View on GitHub
Area-LangService-Diagnostics Bug Impact-Medium
Dominant language
F#
Stars
4.3k
Forks
876
Avg merge
4d 22h
Merged PRs (30d)
144

Description

**Repro steps**

This code:
```fsharp
[]
type MyType(field: string) =
member _.Field = field

module internal MyTypeHelpers =

let f (myType: MyType) =
42

let g myType =
let x = myType
let y = myType
let z = x = y
f myType
```

**Expected behavior**

An error on the line `let z = x = y`

**Actual behavior**

Error on the last line:
![image](https://github.com/dotnet/fsharp/assets/5451366/ffc3efbc-f57e-4cf7-a888-b794e5798aab)

**Related information**

Any of the below fixes the case:
1) Removing explicit type in the first helper - that the first helper infers input as a general type and the second helper infer input as something with equality
2) Adding explicit type to the second helper - just works as expected
![image](https://github.com/dotnet/fsharp/assets/5451366/d5a1bbc2-6e46-4765-96bf-f879e48b6260)

Also, note that the error message mentioned the correct range.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.