enhance conditionals (#2966)

- `x ? (y, w) : (z, w)` => `x ? y : z, w`
This commit is contained in:
Alex Lam S.L
2018-02-28 23:34:48 +08:00
committed by GitHub
parent 0daa199fa8
commit 56e2a369d0
3 changed files with 22 additions and 2 deletions

View File

@@ -332,7 +332,7 @@ cond_7: {
x = 'foo';
x = 'foo';
x = (condition(), 20);
x = z ? 'fuji' : (condition(), 'fuji');
x = (z || condition(), 'fuji');
x = (condition(), 'foobar');
x = y ? a : b;
x = y ? 'foo' : 'fo';

View File

@@ -104,6 +104,7 @@ if_return: {
conditionals: true,
if_return: true,
sequences: true,
side_effects: true,
}
input: {
function f(w, x, y, z) {
@@ -124,7 +125,7 @@ if_return: {
if (w) {
if (y) return;
} else if (z) return;
return x == y || (x && w(), y && z(), !0);
return x == y || (x && w(), y && z()), !0;
}
}
}