extend hoist_props to AST_Arrow & AST_Class (#2527)

fixes #2503
This commit is contained in:
Alex Lam S.L
2017-11-28 22:54:44 +08:00
committed by GitHub
parent 62d2817d6c
commit 755e2a62c6
2 changed files with 32 additions and 10 deletions

View File

@@ -454,17 +454,12 @@ hoist_class_with_new: {
console.log(o.p.name, o.p === o.p, new o.p(o.x).value, new o.p(o.y).value);
}
expect: {
// FIXME: class `o.p` not hoisted due to `new`
var o = {
p: class Foo {
constructor(value) {
this.value = 10 * value;
}
},
x: 1,
y: 2
var o_p = class Foo {
constructor(value) {
this.value = 10 * value;
}
};
console.log(o.p.name, o.p == o.p, new o.p(o.x).value, new o.p(o.y).value);
console.log(o_p.name, true, new o_p(1).value, new o_p(2).value);
}
node_version: ">=6"
expect_stdout: "Foo true 10 20"
@@ -772,3 +767,28 @@ issue_2508_5: {
}
expect_stdout: true
}
issue_2508_6: {
options = {
collapse_vars: true,
hoist_props: true,
reduce_vars: true,
toplevel: true,
unused: true,
}
input: {
var o = {
f: x => {
console.log(x);
}
};
o.f(o.f);
}
expect: {
var o_f = x => {
console.log(x);
};
o_f(o_f);
}
expect_stdout: true
}