Closed brianrourkeboll closed 4 months ago
Awesome - thanks for doing the parallel work here!
How recent of an 8.0.300 does the 'fixed' version need? There's a 'nightly' branch we use to stage these kinds of fixes that pulls from the nightly FCS feeds that you could do the work on once this is merged into main, and main is merged into nightly.
How recent of an 8.0.300 does the 'fixed' version need?
Any version that has https://github.com/dotnet/fsharp/pull/16462 and https://github.com/dotnet/fsharp/pull/16461 in it.
The update would basically look like this:
-let! unnecessaryParentheses = UnnecessaryParentheses.getUnnecessaryParentheses getSourceLine tyRes.GetAST
+let unnecessaryParentheses =
+ (HashSet Range.comparer, tyRes.GetAST)
+ ||> ParsedInput.fold (fun ranges path node ->
+ match node with
+ | SyntaxNode.SynExpr(SynExpr.Paren(expr = inner; rightParenRange = Some _; range = range)) when
+ not (SynExpr.shouldBeParenthesizedInContext getSourceLine path inner)
+ ->
+ ignore (ranges.Add range)
+ ranges
+
+ | SyntaxNode.SynPat(SynPat.Paren(inner, range)) when not (SynPat.shouldBeParenthesizedInContext path inner) ->
+ ignore (ranges.Add range)
+ ranges
+
+ | _ -> ranges)
@brianrourkeboll let me know if you want to move this out of draft - I'm happy to merge it.
@brianrourkeboll let me know if you want to move this out of draft - I'm happy to merge it.
Yeah I just wanted to be sure the CI passed to catch any dumb oversights I might have made.
Thanks for this contribution!
Note: this will need a small update to use https://github.com/dotnet/fsharp/pull/16461 when FSC 8.0.300 is shipped.