-
Notifications
You must be signed in to change notification settings - Fork 833
Description
Is your feature request related to a problem? Please describe.
Currently, the parenthesis of an operator definition or active pattern are not captured in the untyped AST.
Consider the following code and relevant AST:
let (+) x y z = Seq.singleton (x + y + z)
let (|A|_|) v = NoneThese lead to a SynPat.LongIdent as headPat of a SynBinding.
LongIdent
(LongIdentWithDots ([op_Addition], []), None, None,
Pats
[Named
(Wild tmp.fsx (1,8--1,9) IsSynthetic=false, x, false,
None, tmp.fsx (1,8--1,9) IsSynthetic=false);
Named
(Wild tmp.fsx (1,10--1,11) IsSynthetic=false, y, false,
None, tmp.fsx (1,10--1,11) IsSynthetic=false);
Named
(Wild tmp.fsx (1,12--1,13) IsSynthetic=false, z, false,
None, tmp.fsx (1,12--1,13) IsSynthetic=false)], None,
tmp.fsx (1,4--1,13) IsSynthetic=false)
LongIdent
(LongIdentWithDots ([|A|_|], []), None, None,
Pats
[Named
(Wild tmp.fsx (2,12--2,13) IsSynthetic=false, v, false,
None, tmp.fsx (2,12--2,13) IsSynthetic=false)], None,
tmp.fsx (2,4--2,13) IsSynthetic=false)The information of the used parenthesis is currently not captured.
Describe the solution you'd like
I'd like an addition to the Syntax tree to store this information.
On top of my head I'd say some extra information in SynPat.LongIdent and SynPat.Named (in case there are no parameters).
But I'm unsure about the exact shape here.
Perhaps @dsyme or @auduchinok has any ideas here.
Describe alternatives you've considered
We currently use a lot of helper functions in PrettyNaming.fs to detect if we need parenthesis or not.
Additional context
Fantomas issue: fsprojects/fantomas#1842
related: #11481