Skip to content

Commit ef52368

Browse files
auduchinokbaronfel
authored andcommitted
Wrap prefix operator expressions with a paren expression (#9374)
* Update expression ranges * Keep parens in parsed operator uses * Fix getting parameter info for prefix operator invocations
1 parent ab744d4 commit ef52368

File tree

3 files changed

+447
-435
lines changed

3 files changed

+447
-435
lines changed

src/fsharp/pars.fsy

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4011,8 +4011,8 @@ atomicExpr:
40114011
| GLOBAL
40124012
{ SynExpr.Ident (ident(MangledGlobalName, rhs parseState 1)), false }
40134013

4014-
| nameop
4015-
{ SynExpr.Ident ($1), false }
4014+
| identExpr
4015+
{ $1, false }
40164016

40174017
| LBRACK listExprElements RBRACK
40184018
{ $2 (lhs parseState) false, false }
@@ -5334,6 +5334,16 @@ pathOp:
53345334
nameop:
53355335
| identOrOp { $1 }
53365336

5337+
identExpr:
5338+
| ident
5339+
{ SynExpr.Ident($1) }
5340+
5341+
| opName
5342+
{ let m = lhs parseState
5343+
let mLparen = mkFileIndexRange m.FileIndex m.Start (mkPos m.StartLine (m.StartColumn + 1))
5344+
let mRparen = mkFileIndexRange m.FileIndex (mkPos m.EndLine (m.EndColumn - 1)) m.End
5345+
SynExpr.Paren(SynExpr.Ident($1), mLparen, Some mRparen, m) }
5346+
53375347
topSeparator:
53385348
| SEMICOLON { }
53395349
| SEMICOLON_SEMICOLON { }

src/fsharp/service/ServiceParamInfoLocations.fs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ module internal NoteworthyParamInfoLocationsImpl =
4646
| SynExpr.LongIdent (_, LongIdentWithDots(lid, _), _, lidRange)
4747
| SynExpr.DotGet (_, _, LongIdentWithDots(lid, _), lidRange) -> Some (pathOfLid lid, lidRange)
4848
| SynExpr.TypeApp (synExpr, _, _synTypeList, _commas, _, _, _range) -> digOutIdentFromFuncExpr synExpr
49+
| SynExpr.Paren(expr = expr) -> digOutIdentFromFuncExpr expr
4950
| _ -> None
5051

5152
type FindResult =

0 commit comments

Comments
 (0)