From aa173f426161bcef4babc21d2cc158a0d1eb1387 Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Sun, 29 May 2022 14:09:01 +0200 Subject: [PATCH] Fix problem with string in braces introduced in #494 --- src/res_core.ml | 3 ++- tests/printer/expr/expected/switch.res.txt | 4 ++++ tests/printer/expr/switch.res | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/res_core.ml b/src/res_core.ml index dc018ccb..0177e982 100644 --- a/src/res_core.ml +++ b/src/res_core.ml @@ -2772,7 +2772,8 @@ and parseBracedOrRecordExpr p = Parser.expect Rbrace p; expr | _ -> - let constant = Ast_helper.Exp.constant ~loc:field.loc (Parsetree.Pconst_string(s, Some("js"))) in + let tag = if p.mode = ParseForTypeChecker then Some "js" else None in + let constant = Ast_helper.Exp.constant ~loc:field.loc (Parsetree.Pconst_string(s, tag)) in let a = parsePrimaryExpr ~operand:constant p in let e = parseBinaryExpr ~a p 1 in let e = parseTernaryExpr e p in diff --git a/tests/printer/expr/expected/switch.res.txt b/tests/printer/expr/expected/switch.res.txt index 022896ca..2edee31c 100644 --- a/tests/printer/expr/expected/switch.res.txt +++ b/tests/printer/expr/expected/switch.res.txt @@ -21,3 +21,7 @@ let x = switch x { | Universe => () } + +switch count { +| 1 => "one" +} diff --git a/tests/printer/expr/switch.res b/tests/printer/expr/switch.res index b274a503..51607389 100644 --- a/tests/printer/expr/switch.res +++ b/tests/printer/expr/switch.res @@ -19,3 +19,7 @@ let rec updateSum = (node, ~delta) => let x = @attr switch x { | Universe => () } + +switch count { +| 1 => { "one" } +}