Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

F# 5.0 Regression with generic overloads containing nullable #10547

Closed
jbtule opened this issue Nov 25, 2020 · 1 comment
Closed

F# 5.0 Regression with generic overloads containing nullable #10547

jbtule opened this issue Nov 25, 2020 · 1 comment
Assignees
Labels
Impact-High (Internal MS Team use only) Describes an issue with extreme impact on existing code. Regression
Milestone

Comments

@jbtule
Copy link

jbtule commented Nov 25, 2020

There appears to be an issue with type inference and generic overloads that doesn't exist in 4.7, causing the same code not to compile with 5.0.

Repro steps

Provide the steps required to reproduce the problem:

  1. Step A
type OverloadMeths =
    static member Map(m: 'T option, f) = Option.map f m
    static member Map(m: 'T when 'T:null, f) = m |> Option.ofObj |> Option.map f
    //works in 5.0 if you comment out this line
    static member Map(m: 'T Nullable, f) = m |> Option.ofNullable |> Option.map f

[<AllowNullLiteral>]
type Node (child:Node)=
    new() = new Node(null)
    member val child:Node = child with get,set
  1. Step B
let parent = Node()
let b1 = OverloadMeths.Map(parent.child, fun x -> x.child)  //compiler error on this line in F# 5,0
let c1 = OverloadMeths.Map(b1, fun x -> x.child)

Git repo of example with an F# 4.7 and 5.0 project in Visual Studio Solution: https://github.com/jbtule/Fsharp5OverloadIssue

Expected behavior

Compile without error

Actual behavior

Compiler error
Error FS0072 Lookup on object of indeterminate type based on information prior to this program point. A type annotation may be needed prior to this program point to constrain the type of the object. This may allow the lookup to be resolved.

Known workarounds

<LangVersion>4.7</LangVersion>

Related information

Provide any related information (optional):

  • F# 5.0
  • .net 5.0
  • Visual Studio Version 16.8.2
@TIHan TIHan added Area-Compiler Regression Impact-High (Internal MS Team use only) Describes an issue with extreme impact on existing code. labels Nov 25, 2020
@cartermp cartermp modified the milestones: 16.9, Backlog Nov 26, 2020
@dsyme dsyme self-assigned this Dec 1, 2020
@TIHan TIHan assigned TIHan and unassigned dsyme Dec 1, 2020
@TIHan
Copy link
Contributor

TIHan commented Dec 3, 2020

We merged the fix.

@TIHan TIHan closed this as completed Dec 3, 2020
@cartermp cartermp modified the milestones: Backlog, 16.9 Jan 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Impact-High (Internal MS Team use only) Describes an issue with extreme impact on existing code. Regression
Projects
None yet
Development

No branches or pull requests

4 participants