Skip to content

[<FSharp.Core.DefaultValue>] not handled properly on static fields #2739

Description

@chkn

Description

When a static field has the [<FSharp.Core.DefaultValue>] attribute, Fable leaves its value as undefined, which can have different behavior than the .NET default value.

Repro code

type Foo() =
    [<FSharp.Core.DefaultValue>]
    static val mutable private count : int
    static member IncrCount() =
        Foo.count <- Foo.count + 1
        Foo.count

printfn "%d" (Foo.IncrCount())

Expected and actual results

dotnet fsi prints: 1
Fable REPL prints: 0

Related information

  • Fable version: 3.7.0-beta-011
  • Operating system: macOS 10.15.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions