-
Notifications
You must be signed in to change notification settings - Fork 155
Closed
Description
Simple match test with expression in case:
match 1, 3, 3
| 1, 1, 2 or 3 => ok 0
| 1, 2 or 3, 3 => ok 1
| _ => ok 0
Compiles to:
// Generated by LiveScript 1.3.1
var ref$;
switch (ref$ = [1, 3, 3], false) {
case !(1 === ref$[0] && 1 === ref$[1] && 2 === ref$[2] || 3 === ref$[2]):
ok(0);
break;
case !(1 === ref$[0] && 2 === ref$[1] || 3 === ref$[1] && 3 === ref$[2]):
ok(1);
break;
default:
ok(0);
}
The problem in words: Every case-expression is bundled in one long expression.
It should wrap braces around each column so the precedence for each case is preserved.
1 === ref$[1] && 2 === ref$[2] || 3 === ref$[2]
^---- 1 ----^ && ^------------ 2 -------------^ # yay
^------------ 1 -------------^ || ^---- 2 ----^ # nay
Correct output:
(1 === ref$[1]) && (2 === ref$[2] || 3 === ref$[2])
Metadata
Metadata
Assignees
Labels
No labels