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 GitHub
parent 2b44f4ae30
commit 1d407e761e
4 changed files with 107 additions and 2 deletions

View File

@@ -1147,3 +1147,28 @@ var_catch_toplevel: {
}();
}
}
reassign_const: {
options = {
cascade: true,
sequences: true,
side_effects: true,
unused: true,
}
input: {
function f() {
const a = 1;
a = 2;
return a;
}
console.log(f());
}
expect: {
function f() {
const a = 1;
return a = 2, a;
}
console.log(f());
}
expect_stdout: true
}