diff --git a/lib/ast.js b/lib/ast.js index ff1812e6d..4bd42f58a 100644 --- a/lib/ast.js +++ b/lib/ast.js @@ -3968,7 +3968,7 @@ exports.Case = Case = (function(superclass){ i = i$; test = tests[i$]; tar = Chain(target).add(Index(Literal(i), '.', true)); - tests[i] = Chain(test).autoCompare(target ? [tar] : null); + tests[i] = Parens(Chain(test).autoCompare(target ? [tar] : null)); } } if (bool) { diff --git a/src/ast.ls b/src/ast.ls index ca16730bf..658272683 100644 --- a/src/ast.ls +++ b/src/ast.ls @@ -2521,7 +2521,7 @@ class exports.Case extends Node if type is \match for test, i in tests tar = Chain target .add Index (Literal i), \., true - tests[i] = Chain test .auto-compare (if target then [tar] else null) + tests[i] = Parens (Chain test .auto-compare (if target then [tar] else null)) if bool binary = if type is \match then \&& else \|| [t] = tests diff --git a/test/switch.ls b/test/switch.ls index c1f788e1b..cd1b05e68 100644 --- a/test/switch.ls +++ b/test/switch.ls @@ -268,3 +268,8 @@ x = -2 match x | -2 => ok 1 | _ => ok 0 + +match 1, 3, 3 +| 1, 1, 2 or 3 => ok 0 +| 1, 2 or 3, 3 => ok 1 +| _ => ok 0