Skip to content

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

@Lanayx

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

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

    Status

    New

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions