-
-
Notifications
You must be signed in to change notification settings - Fork 202
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
Changes from 1 commit
293f101
e21b02b
3ac9799
85080df
2f7a0af
8496983
f7adb1b
67d8038
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2030,7 +2030,13 @@ and genExpr astContext synExpr ctx = | |
| +> sepNln | ||
| +> genExpr astContext e | ||
| +> unindent | ||
| +> kw WITH !+~ "with" | ||
| +> (fun ctx -> | ||
| let lookupRange = | ||
| ctx.MkRangeWith | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This check is a bit too vague I'm afraid. [<Test>]
let ``comment is still lost`` () =
formatSourceString
false
"""
try
a
// comment
with
| b -> c
"""
config
|> prepend newline
|> should
equal
"""
try
a
// comment
with
| b -> c
"""I would add let (|TryWith|_|) =
function
| SynExpr.TryWith (e, _, cs, mWithToLast, _, _, _) -> Some(e, mWithToLast, cs)
| _ -> Noneand extract the with range as: | TryWith (e, mWithToLast, cs) ->
....
let lookupRange =
ctx.MkRangeWith
(mWithToLast.StartLine, mWithToLast.StartColumn)
(mWithToLast.StartLine, mWithToLast.StartColumn + 4)There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
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 commentThe 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 commentThe 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. Thanks again for all your patience and for engaging in conversation. |
||
| (synExpr.Range.EndLine - 1, 0) | ||
| (synExpr.Range.EndLine, synExpr.Range.EndColumn) | ||
|
|
||
| tokN lookupRange WITH (!+~ "with") ctx) | ||
| +> indentOnWith | ||
| +> sepNln | ||
| +> col sepNln cs (genClause astContext true) | ||
|
|
||

Uh oh!
There was an error while loading. Please reload this page.