Skip to content

Signature generation must include private field info in case of Structs #14310

@T-Gro

Description

@T-Gro

Fsc.exe offers a way to generate signature files out of current implementation.
For most of the F# constructs, a tooling-powered roundtrip just works:
You can generally take an existing imp file, generate .fsi for it, and then compile them together.

When using this on a struct with private fields, the private fields get erased from the generated .fsi.
However, this results in the following error:

    "The type definitions for type 'C' in the signature and implementation are not compatible because the field 'goo' was present in the implementation but not in the signature. **Struct types** must now reveal their fields in the signature for the type, though the fields may still be labelled '**private**' or 'internal'." }
module StructPrivateField =
    [<Struct>]
    [<NoComparison;NoEquality>]
    type C =
        [<DefaultValue>]
        val mutable private goo : byte []        
        member this.P with set(x) = this.goo <- x

Small code sample prepared at ~\tests\FSharp.Compiler.ComponentTests\Signatures\TestCasesForGenerationRoundTrip\struct_private_field_repro.fsx

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-Compiler-SigFileGengeneration of signature files - both compiler and IDEBugImpact-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