-
-
Notifications
You must be signed in to change notification settings - Fork 203
Fix duplicated trivias in combination with double nested try-with statements #1969 #1971
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
Merged
nojaf
merged 8 commits into
fsprojects:master
from
KarolBajkowski:fix/duplicated_trivia_-_nested_try_-_with_#1969
Nov 19, 2021
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
293f101
fix WIP draft
KarolBajkowski e21b02b
fix test name to avoid confusion
KarolBajkowski 3ac9799
resolve some review comments
KarolBajkowski 85080df
cleanup
KarolBajkowski 2f7a0af
nits
KarolBajkowski 8496983
reformat using 'dotnet fantomas src -r'
KarolBajkowski f7adb1b
follow test code conventions
KarolBajkowski 67d8038
cover one more case
KarolBajkowski 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
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
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 check is a bit too vague I'm afraid.
It will fail if the with keyword is higher up:
I would add
mWithToLastto the active pattern:(parser source)
and extract the with range as:
Uh oh!
There was an error while loading. Please reload this page.
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.
I updated the code with your suggestion. Thank you for your help :) I hope that will work now, even though it's probably my worst PR in my life :D
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.
I had to miss your suggested code :/ I'm wondering why this code works even with
+3like(mWithToLast.StartLine, mWithToLast.StartColumn + 3)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.
Yeah, well that might be an offset by 1 error on the token side.
The trivia node that has the comment is going from
3,0 - 3,3mWithToLastshall in this case span from3,0--6,8.tokNwill try and look withinlookupRangewhether theWITHtoken exists.Inclusively, so that is why it is dangerous to look in a range that is too long.
I took
+ 4because thewithkeyword is 4 characters long.Once dotnet/fsharp#12400 is merged, we can look for that exact range (via ASTTransformer) and use range contains. Don't worry about this last bit, that is something for in the future.
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.
Thanks for explanation! It really helps. But I must admit for me it was too much rush. I have to slowly finish fantomas youtube videos and look again at the source code and assembly all those puzzles together. I think I intuitively understand what's going on, but I need better understanding... TBH this is my first contact with compiler source code especially in F# (which I think basics I know very well but still I'm wrapping my head around some F# features/patterns which are not common in OOP)
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.
Yes, it took me a lot of time to understand this project when I first started out.
That is why I made these videos, to speed up this process for newcomers.
But I'm well aware not everything immediately clicks. Especially all those custom operators.
At first you sorta conceptually understand what they do, and later you really start understanding the events they add to the context.
I'm in the same boot that before this project, I never saw a compiler up close.
That was also a very overwhelming brave new world, but with all things, eventually, you get the hang of it.
Thanks again for all your patience and for engaging in conversation.