-
Notifications
You must be signed in to change notification settings - Fork 786
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
with
syntax on records restricts return types unnecessarily
#1175
Comments
Presumably examples that involve the value restriction would hit this? |
I can't specifically remember any reason for this restriction. It would be good to check if this is a design change (according to the F# language spec). |
@dsyme, it would require the language spec to change.
You are correct the value restriction would bite here: let update3 =
ref (fun f (r : Record<int>) -> { r with poly = f r.poly })
let update4 =
ref (fun f (r : Record<int>) -> { plain = r.plain; poly = f r.poly }) At the moment, |
Chatted with @mjp41 and we decided to close this since it would be a breaking change (due to the calue restriction). |
with
syntax for records does not allow the polymorphic type to be different between theoriginal and new record.
Repro steps
Expected behavior
Typing
update1
with the specified type. I always consideredwith
on recordsas shorthand for expanding the record creation, but the typing does not treat
them like that.
Actual behavior
The
update1
the'b
and'a
are unified unnecessarily.Known workarounds
Expanding the
with
to write the whole underlying record directly.Related information
This is on Visual Studio 2015 Update 2.
I am happy to fix this, but I can't currently work out if inferring a more general type
would potentially break existing code. Are there any corner cases where principle
typing does not work for F#?
The text was updated successfully, but these errors were encountered: