-
Notifications
You must be signed in to change notification settings - Fork 831
Support explicit struct optional args (?x=…)
#19113
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
Support explicit struct optional args (?x=…)
#19113
Conversation
❗ Release notes requiredCaution No release notes found for the changed paths (see table below). Please make sure to add an entry with an informative description of the change as well as link to this pull request, issue and language suggestion if applicable. Release notes for this repository are based on Keep A Changelog format. The following format is recommended for this repository:
If you believe that release notes are not necessary for this PR, please add NO_RELEASE_NOTES label to the pull request. You can open this PR in browser to add release notes: open in github.dev
|
| let argTy = | ||
| if isOpt && voptionParams |> Set.contains id.idText && isOptionTy g argTy then mkValueOptionTy g (destOptionTy g argTy) | ||
| else argTy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit of hack and might cause other problems.
I wonder if it could/should be done here instead?
| and TcMethodApplication_UniqueOverloadInference |
fsharp/src/Compiler/Checking/Expressions/CheckExpressions.fs
Lines 9966 to 9968 in cfda5f6
| // Build the CallerArg values for the caller's arguments. | |
| // Fake up some arguments if this is the use of a method as a first class function | |
| let unnamedCurriedCallerArgs, namedCurriedCallerArgs, returnTy = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...Lol, yeah, it broke a bunch of stuff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Meh. Won't work there, either.
We'd really need to somehow defer checking the kind of the optional param till overload resolution...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, silly. I forgot to check whether the caller arg was an explicit optional arg here:
fsharp/src/Compiler/Checking/ConstraintSolver.fs
Lines 3216 to 3219 in 669a6bb
| let callerTy = | |
| let g = csenv.g | |
| if isValueOptionTy g calledArgTy && isOptionTy g callerTy then mkValueOptionTy g (destOptionTy g callerTy) | |
| else callerTy |
But even if I did check that, this approach seems potentially wrong: is it possible to know here that a different overload wouldn't be picked if we didn't swap out the caller arg type? Would doing some subset of the overload resolution analysis here be enough, e.g., at least making sure that the explicit optional caller arg's position lined up with at least one struct optional arg's position on a candidate method?
Description
Fixes #19074.
?x=….Checklist