Skip to content

Recursive type with a legal Zero value fails to compile #12379

@brianberns

Description

@brianberns

Consider the following code:

type Foo<'t when 't : (static member Zero : 't)> =
    | MkFoo of 't

type Bar =
    | Nil
    | MkBar of Foo<Bar>   // Error: The type 'Bar' does not support the operator 'get_Zero'

    static member Zero
        with get () = Nil

let zeroBar = LanguagePrimitives.GenericZero<Bar>   // this compiles fine, so Bar definitely has a legal Zero value

Expected behavior

Should compile with no problems.

Actual behavior

Compiler error: The type 'Bar' does not support the operator 'get_Zero'

Known workarounds

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-Compiler-CheckingType checking, attributes and all aspects of logic checkingArea-Compiler-SRTPbugs in SRTP inference, resolution, witness passing, code genBugImpact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.

    Type

    Projects

    Status

    New

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions