-
Notifications
You must be signed in to change notification settings - Fork 789
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
When struct val field name equals constructor argument "ambiguous overload" #9942
Comments
I've been hit by this too, I think it's caused by the compiler thinking it's a field assignment for field |
Hmm, not sure it's related, but it seems in the same ballpark: #9517 My hunch is that it has the same cause. |
Changed it to int as it has nothing to do with boolean expression confusion :) I think indeed there is some field and constructor argument confusion going on but it does not seem too related to #9517 |
Worth noting that this has no issue, which I expect to be the usual case: open System
[<Struct>]
type C =
val private x: int
new (x) = { x = x }
let test = C(0) Seems like a reasonable thing to also allow the named argument here |
@cartermp this is mostly problematic when there are multiple constructors, of which at least one is for a generic field. |
Is it possible to use a self reference in the constructor definition, to help disambiguate? |
So do we agree this is legitimately considered ambiguous?
Here In this case, the issue is that the |
I would indeed say it's ambiguous without the private access modifier |
When struct val field name equals constructor argument "ambiguous overload"
https://sharplab.io/#v2:EYLgxg9gTgpgtADwGwBYA0AbEAzAzgHwgAcYA7AAgGUBPXAFxgFsBYAKDbYG0AeSuqAK5g6APgC6bOtRLkAwuQC8bcivIA3AIYZyRKAEtNDcghDk9pOstWkYAd3IAKBAEpF5AN7G3CcgF8rKmwYMHTkDPRusk5uAAzOQA===
Changing
new (x)
to saynew (y)
(and its references) allows the resolution to succeed. ¯\(ツ)/¯The text was updated successfully, but these errors were encountered: