consistently reduce const safe literals (#2411)

fixes #2406
This commit is contained in:
Alex Lam S.L
2017-10-28 11:36:44 +08:00
committed by GitHub
parent 6ab73c7bd5
commit 6371e2ee63
2 changed files with 86 additions and 1 deletions

View File

@@ -3111,3 +3111,88 @@ const_expr_2: {
}
expect_stdout: "2 2"
}
issue_2406_1: {
options = {
reduce_vars: true,
toplevel: false,
unused: true,
}
input: {
const c = {
fn: function() {
return this;
}
};
let l = {
fn: function() {
return this;
}
};
var v = {
fn: function() {
return this;
}
};
console.log(c.fn(), l.fn(), v.fn());
}
expect: {
const c = {
fn: function() {
return this;
}
};
let l = {
fn: function() {
return this;
}
};
var v = {
fn: function() {
return this;
}
};
console.log(c.fn(), l.fn(), v.fn());
}
}
issue_2406_2: {
options = {
reduce_vars: true,
toplevel: true,
unused: true,
}
input: {
const c = {
fn: function() {
return this;
}
};
let l = {
fn: function() {
return this;
}
};
var v = {
fn: function() {
return this;
}
};
console.log(c.fn(), l.fn(), v.fn());
}
expect: {
console.log({
fn: function() {
return this;
}
}.fn(), {
fn: function() {
return this;
}
}.fn(), {
fn: function() {
return this;
}
}.fn());
}
}