Git Product home page Git Product logo

Comments (5)

edgarfgp avatar edgarfgp commented on May 23, 2024

I'm not able to reproduce this on main with withLangVersion80 or withLangVersionPreview.

Edit: Adding some extra tests for this could be useful

Edit 2: Looks like this warning is disabled by default(It was not like that in the past).

Anyway. Yeah it can be reproduced. See:

[<Fact>]
let ``Warning FS3560 triggered upon nested update even if other fields of nested record are copied`` () =
        Fsx """
type Q = { x: int; y: string }
type T = { q: Q }
let a = { q = { x = 5; y = "abc" } }
let b = { a with q.x = 5 }
        """
        |> withLangVersion80
        |> withOptions ["--warnon:FS3560"]
        |> typecheck
        |> shouldFail
        |> withDiagnostics [
            (Warning 3560, Line 5, Col 9, Line 5, Col 27, "This copy-and-update record expression changes all fields of record type 'Test.T'. Consider using the record construction syntax instead.")
        ]

from fsharp.

kerams avatar kerams commented on May 23, 2024

Why do you think this is a bug?

from fsharp.

brianrourkeboll avatar brianrourkeboll commented on May 23, 2024

Why do you think this is a bug?

Yeah, I guess technically the message is correct in that

{ a with q.x = 5 }

could be

{ q = { a.q with x = 5 } }

But I can also see why someone would view copying-and-updating the two nested records in this case as a single copy-and-update operation (now that that's possible), rather than as an outer construction operation and an inner copy-and-update operation.

from fsharp.

abonie avatar abonie commented on May 23, 2024

We should remove this warning and do what the warning says during code-gen or optimization

from fsharp.

abonie avatar abonie commented on May 23, 2024

Closing, since we plan to address it in a different manner. Btw this warning is disabled by default as Edgar said (except in some old version of the SDK)

from fsharp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.