diff --git a/src/Fantomas.Tests/PatternMatchingTests.fs b/src/Fantomas.Tests/PatternMatchingTests.fs index c95eaedc99..7f08c59a9a 100644 --- a/src/Fantomas.Tests/PatternMatchingTests.fs +++ b/src/Fantomas.Tests/PatternMatchingTests.fs @@ -1270,7 +1270,6 @@ let private formatResponse<'options> () = } """ -[] [] let ``match inside match expression, 1400`` () = formatSourceString @@ -1301,7 +1300,6 @@ match | _ -> failwith "" """ -[] [] let ``match bang inside match expression`` () = formatSourceString @@ -1332,7 +1330,6 @@ match | _ -> failwith "" """ -[] [] let ``match inside match bang expression`` () = formatSourceString @@ -1363,7 +1360,6 @@ match! | _ -> failwith "" """ -[] [] let ``match bang inside match bang expression`` () = formatSourceString diff --git a/src/Fantomas/CodePrinter.fs b/src/Fantomas/CodePrinter.fs index 1aa070eb7a..f3b50a0004 100644 --- a/src/Fantomas/CodePrinter.fs +++ b/src/Fantomas/CodePrinter.fs @@ -1676,12 +1676,7 @@ and genExpr astContext synExpr ctx = sepOpenTFor lpr +> genExpr astContext e +> sepCloseTFor rpr pr - | CompApp (s, e) -> - !-s - +> sepSpace - +> sepOpenS - +> genExpr { astContext with IsNakedRange = true } e - +> sepCloseS + // This supposes to be an infix function, but for some reason it isn't picked up by InfixApps | App (Var "?", e :: es) -> match es with @@ -1694,24 +1689,6 @@ and genExpr astContext synExpr ctx = +> col sepSpace es (genExpr astContext) +> sepCloseT - | App (Var "..", [ e1; e2 ]) -> - let expr = - genExpr astContext e1 +> sepSpace -- ".." - +> sepSpace - +> genExpr astContext e2 - - ifElse astContext.IsNakedRange expr (sepOpenS +> expr +> sepCloseS) - | App (Var ".. ..", [ e1; e2; e3 ]) -> - let expr = - genExpr astContext e1 +> sepSpace -- ".." - +> sepSpace - +> genExpr astContext e2 - +> sepSpace - -- ".." - +> sepSpace - +> genExpr astContext e3 - - ifElse astContext.IsNakedRange expr (sepOpenS +> expr +> sepCloseS) // Separate two prefix ops by spaces | PrefixApp (s1, PrefixApp (s2, e)) -> !-(sprintf "%s %s" s1 s2) +> genExpr astContext e | PrefixApp (s, App (e, [ Paren _ as p ])) diff --git a/src/Fantomas/SourceParser.fs b/src/Fantomas/SourceParser.fs index 10580c7ca2..4cac710b75 100644 --- a/src/Fantomas/SourceParser.fs +++ b/src/Fantomas/SourceParser.fs @@ -3,7 +3,6 @@ module internal Fantomas.SourceParser open System open FSharp.Compiler.Syntax open FSharp.Compiler.Syntax.PrettyNaming -open FSharp.Compiler.Tokenization.FSharpKeywords open FSharp.Compiler.Text open FSharp.Compiler.Xml open Fantomas @@ -40,7 +39,7 @@ let (|Ident|) (s: Ident) = if IsActivePatternName ident then sprintf "(%s)" (DecompileOpName ident) else - PrettyNaming.AddBackticksToIdentifierIfNeeded ident + AddBackticksToIdentifierIfNeeded ident let (|LongIdent|) (li: LongIdent) = li @@ -802,11 +801,6 @@ let (|NewTuple|_|) = | SynExpr.New (_, t, (ConstExpr (SynConst.Unit, _) as px), _) -> Some(t, px) | _ -> None -let (|CompApp|_|) = - function - | SynExpr.App (_, _, Var "seq", (SynExpr.App _ as e), _) -> Some("seq", e) - | _ -> None - /// Only process prefix operators here let (|PrefixApp|_|) = function @@ -822,8 +816,7 @@ let (|PrefixApp|_|) = let (|InfixApp|_|) synExpr = match synExpr with | SynExpr.App (_, true, (Var "::" as e), Tuple ([ e1; e2 ], _), _) -> Some("::", e, e1, e2) - // Range operators need special treatments, so we exclude them here - | SynExpr.App (_, _, SynExpr.App (_, true, (Var s as e), e1, _), e2, _) when s <> ".." -> Some(s, e, e1, e2) + | SynExpr.App (_, _, SynExpr.App (_, true, (Var s as e), e1, _), e2, _) -> Some(s, e, e1, e2) | _ -> None let (|NewlineInfixApp|_|) =