-
Notifications
You must be signed in to change notification settings - Fork 838
Remove LetOrUseKeyword from SynExprLetOrUseTrivia #19090
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
Conversation
✅ No release notes required |
|
Another issue I saw is the comp {
let! a = b in
and! c = d in
and! e = f in
()
}I made some changes for that as well so that any |
|
Didn't take this into account yet but should the range of |
I'd say no. I see it as a part of a Even though it only makes sense in I'd put it to |
Yeah, makes sense but might be a bit tricky to implement. As LetOrUse now looks like: | LetOrUse of
// isRecursive: true for 'let rec' and 'use rec' bindings, false for 'let' and 'use' bindings
isRecursive: bool *
/// isUse: true for 'use' and 'use!' bindings, false for 'let' and 'let!'
isUse: bool *
// isFromSource: flag indicates whether a binding was explicitly written by the user in the source code versus generated by the compiler during transformations.
isFromSource: bool *
// isBang: true for 'let!' and 'use!' bindings, false for 'let' and 'use' bindings
isBang: bool *
bindings: SynBinding list *
body: SynExpr *
range: range(in my PR here) Having a list of optional A separate list is messy because it forces assuming both lists will have the same length. So it makes more sense to have a wrapper type that bundles SynBinding with the optional type SynBindingAndMaybeAnInKeyword = {
Binding: SynBinding;
InKeyword: Range option;
}Once we're on that train of thought, it's not a stretch to put it in the SynBinding trivia like I currently do. It does not help that the code constructing these values is scattered across the parser. My take is that including it in SynBinding trivia is the most pragmatic approach. |
Why would it be a list? There can be at most one |
Example: comp {
let! a = b
and! c = d in
and! e = f in
()
}Becomes This used to be 1 After the refactor in F# 10 this information is now lost. |
|
@nojaf Interesting, thanks! I suspect that allowing multiple The original RFC mentions the syntax that follows the rules of regular If that's a correct assumption, then the most sound way to proceed would be to disallow the extra @dsyme May we ask your opinion on the topic, please? |
|
Do you foresee a way of disallowing that syntax with a reasonable recovery and an error message? (We have to assume that people don't read release notes and don't like their parsing of "yesterday it worked fine" code fail mid-file) If not easily doable, a staged approach (i.e. warning on this being a bug first, then remove 1 version later) would work for sure. |
Yes, since it's already parsed properly we can just add an additional error reporting. |
|
Okay, this is now ready for review! Future PRs can address the |
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.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
auduchinok
left a comment
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.
@nojaf This is fantastic, thanks!
|
Hi @T-Gro , I do not get the failures in |
|
@nojaf : Maybe best to reproduce with a syntax tree test for some very basic |
|
@T-Gro thanks that did explain it. Green now |
Description
As mentioned on #18825 (comment)
It would be most convenient if a
SynBindingholds all the information to print itself on its own.By extending
SynLeadingKeywordwe can do exactly that.Test cases added
Performance benchmarks added in case of performance changes
Release notes entry updated: