-
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
Closed
brianrourkeboll
wants to merge
2
commits into
dotnet:main
from
brianrourkeboll:explicit-struct-optional-args
+56
−1
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
...BasicGrammarElements/MemberDefinitions/OptionalArguments/RefAndStructOptionalArgParity.fs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| module M | ||
|
|
||
| type T = | ||
| static member MRef (?x : int) = () | ||
| static member MStruct ([<Struct>] ?x : int) = () | ||
|
|
||
| T.MRef 3 | ||
| T.MRef () | ||
| T.MRef (x=3) | ||
| T.MRef (?x=None) | ||
| T.MRef (?x=Some 3) | ||
|
|
||
| T.MStruct 3 | ||
| T.MStruct () | ||
| T.MStruct (x=3) | ||
| T.MStruct (?x=ValueNone) | ||
| T.MStruct (?x=ValueSome 3) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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?
fsharp/src/Compiler/Checking/Expressions/CheckExpressions.fs
Line 9945 in cfda5f6
fsharp/src/Compiler/Checking/Expressions/CheckExpressions.fs
Lines 9966 to 9968 in cfda5f6
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
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?