Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Commit ce2eb11

Browse files
authored
Fix problem with string in braces introduced in #494 (#509)
1 parent 0957217 commit ce2eb11

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

src/res_core.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2772,7 +2772,8 @@ and parseBracedOrRecordExpr p =
27722772
Parser.expect Rbrace p;
27732773
expr
27742774
| _ ->
2775-
let constant = Ast_helper.Exp.constant ~loc:field.loc (Parsetree.Pconst_string(s, Some("js"))) in
2775+
let tag = if p.mode = ParseForTypeChecker then Some "js" else None in
2776+
let constant = Ast_helper.Exp.constant ~loc:field.loc (Parsetree.Pconst_string(s, tag)) in
27762777
let a = parsePrimaryExpr ~operand:constant p in
27772778
let e = parseBinaryExpr ~a p 1 in
27782779
let e = parseTernaryExpr e p in

tests/printer/expr/expected/switch.res.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,7 @@ let x =
2121
switch x {
2222
| Universe => ()
2323
}
24+
25+
switch count {
26+
| 1 => "one"
27+
}

tests/printer/expr/switch.res

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,7 @@ let rec updateSum = (node, ~delta) =>
1919
let x = @attr switch x {
2020
| Universe => ()
2121
}
22+
23+
switch count {
24+
| 1 => { "one" }
25+
}

0 commit comments

Comments
 (0)