Skip to content

Commit

Permalink
Parens: Keep parentheses around non-struct tuples in & patterns (#1…
Browse files Browse the repository at this point in the history
…6391)

* This case was missed in the original PR

* Add entry to FCS release notes
  • Loading branch information
brianrourkeboll authored Dec 7, 2023
1 parent ade7946 commit 257702e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/release-notes/FSharp.Compiler.Service/8.0.200.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- Parens analysis: miscellaneous fixes - https://github.com/dotnet/fsharp/pull/16262
- Parens: Keep parentheses around non-struct tuples in `&` patterns - https://github.com/dotnet/fsharp/pull/16391
- Parens analysis: fix some parenthesization corner-cases in record expressions - https://github.com/dotnet/fsharp/pull/16370
- Fixes #16359 - correctly handle imports with 0 length public key tokens - https://github.com/dotnet/fsharp/pull/16363
3 changes: 3 additions & 0 deletions src/Compiler/Service/ServiceAnalysis.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1657,7 +1657,10 @@ module UnnecessaryParentheses =
| SynPat.Tuple _, SynPat.As _

// x, (y, z)
// x & (y, z)
// (x, y) & z
| SynPat.Tuple _, SynPat.Tuple(isStruct = false)
| SynPat.Ands _, SynPat.Tuple(isStruct = false)

// A, (B | C)
// A & (B | C)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1765,7 +1765,7 @@ module Patterns =
Ands(pats |> List.updateAt i (Paren inner)), Ands(pats |> List.updateAt i inner)
else
Ands(pats |> List.updateAt i (Paren inner)), Ands(pats |> List.updateAt i (Paren inner))
| Ands pats, (Or _ | As _) ->
| Ands pats, (Or _ | As _ | Tuple _) ->
for i, _ in Seq.indexed pats do
Ands(pats |> List.updateAt i (Paren inner)), Ands(pats |> List.updateAt i (Paren inner))
| Ands pats, _ ->
Expand Down

0 comments on commit 257702e

Please sign in to comment.