Skip to content

Nested field update doesn't type-check properly #18940

Closed

Description

@Lanayx

Repro steps

type SubSubTest = {
    Z: int
}

type SubTest = {
    Y: SubSubTest
}

type Test = {
    X: SubTest
}

let getTest () =
    Unchecked.defaultof<Test>


[<EntryPoint>]
let main argv =
    {
        getTest () with
            X.Y.Z = 123
    } |> ignore
    0

Expected behavior

Code compiles just fine

Actual behavior

0>Program.fs(21,13): Error FS0039 : The type 'SubTest' does not define the field, constructor or member 'X'.

Known workarounds

Move getTest () to a variable

    let t = getTest ()
    {
        t with
            X.Y.Z = 123
    } |> ignore

Related information

Reproduces with .NET 8, .NET 9, .NET 10 sdks

Activity

  1. added theissue type on Sep 26, 2025
  2. added this to the Backlog milestone on Sep 26, 2025
  3. added
    Area-Compiler-CheckingType checking, attributes and all aspects of logic checking
    Impact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.
    and removed on Sep 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-Compiler-CheckingType checking, attributes and all aspects of logic checkingBugImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.

    Type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions