fix invalid transform on const (#1919)

- preserve (re)assignment to `const` for runtime error
- suppress `cascade` on `const`, as runtime behaviour is ill-defined
This commit is contained in:
Alex Lam S.L
2017-05-12 04:51:44 +08:00
committed by alexlamsl
parent 13e5e33448
commit aa7e8783f8
4 changed files with 106 additions and 1 deletions

View File

@@ -610,3 +610,27 @@ delete_seq_6: {
}
expect_stdout: true
}
reassign_const: {
options = {
cascade: true,
sequences: true,
side_effects: true,
}
input: {
function f() {
const a = 1;
a++;
return a;
}
console.log(f());
}
expect: {
function f() {
const a = 1;
return a++, a;
}
console.log(f());
}
expect_stdout: true
}