Comments (5)
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.
Why do you think this is a bug?
from fsharp.
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.
We should remove this warning and do what the warning says during code-gen or optimization
from fsharp.
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)
- The release notes on the public packages point to internal links HOT 1
- [Automated] PRs inserted in VS build main-34920.14
- Impossible viable fork HOT 2
- Impossible viable fork HOT 14
- Compiler allows non-functions to be bound to active pattern names HOT 4
- Consider deprecating desktop framework version of the F# compiler and FSI program HOT 6
- [Automated] PRs inserted in VS build feature.debugger.main-34920.221
- `MultipleDiagnosticsLoggers.Parallel` deadlock HOT 1
- #nowarn does not support the FS prefix on error codes to disable warning about HOT 1
- dotnet fsi crashes with lines longer than terminal width HOT 4
- Inline warning resulting in run time error (NotSupportedException) HOT 2
- An F# or C# shebang executable should use a cached binary on subsequent runs
- F# files moved with by dragging HOT 1
- Enable F# Code Metrics and Analysis
- Improve onhover tooltip for visual studio HOT 1
- Support / fix replacing reference (Refactor -> Rename) of F# operator
- [Feature request] Support solution view where projects are ordered based on number of dependent projects. HOT 2
- F# - Add Function Dependency Status to Functions/IntelliSense for F# (like C# has)
- Internal error when dotting into delegate with 2 or more type parameters
- I'm getting unwanted navigation when holding `Ctrl` and hovering over operators like `&&` or `>`. Not sure if caused by this PR or a bug in VS. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fsharp.