Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Record spread expression: FS0765 for a record with a [<DefaultValue>] field #21050

Backlog

Description

@T-Gro

Record spread expression fails when the record has a [<DefaultValue>] field.

Repro steps

type R = { A : int; [<DefaultValue>] mutable B : int }
let r : R = { A = 1 }
let copy : R = { ...r }

Expected behavior

Compiles. B is zero-initialized, as in { A = 1 }.

Actual behavior

error FS0765: Extraneous fields have been given values

Known workarounds

N/A

Related information

  • F# Interactive 15.2.101.0 for F# 11.0, --langversion:preview
  • macOS, .NET

Activity

  1. added this to the Backlog milestone on Nov 30, 2026
  2. brianrourkeboll commented on Nov 30, 2026

    @brianrourkeboll
    Contributor

    ...Somehow I did not know that you could use [<DefaultValue>] like that with record fields.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions