Skip to content

Regression with constraints produced by Nullable #11344

Description

@gusty

Repro steps

Run the following in fsi:

open System

type JsonValue = JNull

type JsonEncoding = JsonEncoding with
    static member nullableE encoder (x: Nullable<'a>) = if x.HasValue then encoder x.Value else JNull
    static member nullable  codec = JsonEncoding.nullableE codec

Expected behavior

Compile OK

Actual behavior

~vs3D37.fsx(7,37): error FS0193: Type constraint mismatch. The type 
    ''a'    
is not compatible with type
    'Nullable<'a>'    

Known workarounds

  • Don't upgrade Visual Studio
  • Transform the first method to a let bind

Related information

  • Operating system: Windows
  • Editing Tools (e.g. Visual Studio Version, Visual Studio): Works in VS 16.8.3, doesn't work in VS 16.9.3

Activity

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

Metadata

Metadata

Assignees

Labels

Impact-High(Internal MS Team use only) Describes an issue with extreme impact on existing code.Regression

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions