Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions docs/release-notes/FSharp.Compiler.Service/8.0.200.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
- Miscellaneous fixes to parens analysis - https://github.com/dotnet/fsharp/pull/16262
- Fixes #16359 - correctly handle imports with 0 length public key tokens - https://github.com/dotnet/fsharp/pull/16363
- Parens analysis: miscellaneous fixes - https://github.com/dotnet/fsharp/pull/16262
- 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
30 changes: 30 additions & 0 deletions src/Compiler/Service/ServiceAnalysis.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1325,6 +1325,36 @@ module UnnecessaryParentheses =
->
ValueNone

| SynExpr.Record(copyInfo = Some(SynExpr.Paren(expr = Is inner), _)), Dangling.Problematic _
| SynExpr.AnonRecd(copyInfo = Some(SynExpr.Paren(expr = Is inner), _)), Dangling.Problematic _ -> ValueNone

| SynExpr.Record(recordFields = recordFields), Dangling.Problematic _ ->
let rec loop recordFields =
match recordFields with
| [] -> ValueSome range
| SynExprRecordField(expr = Some(SynExpr.Paren(expr = Is inner)); blockSeparator = Some _) :: SynExprRecordField(
fieldName = SynLongIdent(id = id :: _), _) :: _ ->
if problematic inner.Range id.idRange then
ValueNone
else
ValueSome range
| _ :: recordFields -> loop recordFields

loop recordFields

| SynExpr.AnonRecd(recordFields = recordFields), Dangling.Problematic _ ->
let rec loop recordFields =
match recordFields with
| [] -> ValueSome range
| (_, Some _blockSeparator, SynExpr.Paren(expr = Is inner)) :: (SynLongIdent(id = id :: _), _, _) :: _ ->
if problematic inner.Range id.idRange then
ValueNone
else
ValueSome range
| _ :: recordFields -> loop recordFields

loop recordFields

| SynExpr.Paren _, SynExpr.Typed _
| SynExpr.Quote _, SynExpr.Typed _
| SynExpr.AnonRecd _, SynExpr.Typed _
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,48 @@ in x

// AnonRecd
"id ({||})", "id {||}"
"{| A = (fun () -> ()) |}", "{| A = fun () -> () |}"
"{| A = (fun () -> ()); B = 3 |}", "{| A = (fun () -> ()); B = 3 |}"
"{| A = (let x = 3 in x); B = 3 |}", "{| A = (let x = 3 in x); B = 3 |}"
"{| (try {||} with _ -> reraise ()) with A = 4 |}", "{| (try {||} with _ -> reraise ()) with A = 4 |}"

"
{| A = (fun () -> ())
B = 3 |}
",
"
{| A = fun () -> ()
B = 3 |}
"

"
{| A = (fun () -> ()); B = (fun () -> ())
C = 3 |}
",
"
{| A = (fun () -> ()); B = fun () -> ()
C = 3 |}
"

"
{| A = (let x = 3 in x)
B = 3 |}
",
"
{| A = let x = 3 in x
B = 3 |}
"

"
{| (try {||} with _ -> reraise ())
with
A = 4 |}
",
"
{| (try {||} with _ -> reraise ())
with
A = 4 |}
"

// ArrayOrList
"id ([])", "id []"
Expand All @@ -928,6 +970,49 @@ in x

// Record
"id ({ A = x })", "id { A = x }"
"{ A = (fun () -> ()) }", "{ A = fun () -> () }"
"{ A = (fun () -> ()); B = 3 }", "{ A = (fun () -> ()); B = 3 }"
"{ A = (let x = 3 in x); B = 3 }", "{ A = (let x = 3 in x); B = 3 }"
"{ A.B.C.D.X = (match () with () -> ()); A.B.C.D.Y = 3 }", "{ A.B.C.D.X = (match () with () -> ()); A.B.C.D.Y = 3 }"
"{ (try { A = 3 } with _ -> reraise ()) with A = 4 }", "{ (try { A = 3 } with _ -> reraise ()) with A = 4 }"

"
{ A = (fun () -> ())
B = 3 }
",
"
{ A = fun () -> ()
B = 3 }
"

"
{ A = (let x = 3 in x)
B = 3 }
",
"
{ A = let x = 3 in x
B = 3 }
"

"
{ A.B.C.D.X = (match () with () -> ())
A.B.C.D.Y = 3 }
",
"
{ A.B.C.D.X = match () with () -> ()
A.B.C.D.Y = 3 }
"

"
{ (try { A = 3 } with _ -> reraise ())
with
A = 4 }
",
"
{ (try { A = 3 } with _ -> reraise ())
with
A = 4 }
"

// New
"id (new obj())", "id (new obj())"
Expand Down