mark AST_Var out of block scopes (#2700)
This commit is contained in:
@@ -5032,10 +5032,8 @@ merge(Compressor.prototype, {
|
|||||||
var init;
|
var init;
|
||||||
if (fixed instanceof AST_This) {
|
if (fixed instanceof AST_This) {
|
||||||
if (!(d.orig[0] instanceof AST_SymbolFunarg)
|
if (!(d.orig[0] instanceof AST_SymbolFunarg)
|
||||||
&& all(d.references, d.scope.is_block_scope() ? function(ref) {
|
&& all(d.references, function(ref) {
|
||||||
return d.scope === ref.scope;
|
return d.scope === ref.scope;
|
||||||
} : function(ref) {
|
|
||||||
return d.scope === ref.scope.get_defun_scope();
|
|
||||||
})) {
|
})) {
|
||||||
init = fixed;
|
init = fixed;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -284,6 +284,10 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options){
|
|||||||
}
|
}
|
||||||
node.thedef = sym;
|
node.thedef = sym;
|
||||||
node.reference(options);
|
node.reference(options);
|
||||||
|
if (node.scope.is_block_scope()
|
||||||
|
&& !(sym.orig[0] instanceof AST_SymbolBlockDeclaration)) {
|
||||||
|
node.scope = node.scope.get_defun_scope();
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// ensure mangling works if catch reuses a scope variable
|
// ensure mangling works if catch reuses a scope variable
|
||||||
|
|||||||
@@ -1555,10 +1555,10 @@ defun_label: {
|
|||||||
!function() {
|
!function() {
|
||||||
console.log(function(a) {
|
console.log(function(a) {
|
||||||
L: {
|
L: {
|
||||||
if (a) break L;
|
if (2) break L;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}(2));
|
}());
|
||||||
}();
|
}();
|
||||||
}
|
}
|
||||||
expect_stdout: true
|
expect_stdout: true
|
||||||
@@ -3366,9 +3366,7 @@ obj_for_1: {
|
|||||||
console.log(i);
|
console.log(i);
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
// TODO make this work on harmony
|
for (var i = { a: 1 }.a--; i; i--)
|
||||||
var o = { a: 1 };
|
|
||||||
for (var i = o.a--; i; i--)
|
|
||||||
console.log(i);
|
console.log(i);
|
||||||
}
|
}
|
||||||
expect_stdout: "1"
|
expect_stdout: "1"
|
||||||
@@ -3407,9 +3405,7 @@ array_forin_1: {
|
|||||||
console.log(b);
|
console.log(b);
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
// TODO make this work on harmony
|
for (var b in [ 1, 2, 3 ])
|
||||||
var a = [ 1, 2, 3 ];
|
|
||||||
for (var b in a)
|
|
||||||
console.log(b);
|
console.log(b);
|
||||||
}
|
}
|
||||||
expect_stdout: [
|
expect_stdout: [
|
||||||
@@ -3454,9 +3450,7 @@ array_forof_1: {
|
|||||||
console.log(b);
|
console.log(b);
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
// TODO make this work on harmony
|
for (var b of [ 1, 2, 3 ])
|
||||||
var a = [ 1, 2, 3 ];
|
|
||||||
for (var b of a)
|
|
||||||
console.log(b);
|
console.log(b);
|
||||||
}
|
}
|
||||||
expect_stdout: [
|
expect_stdout: [
|
||||||
@@ -5160,10 +5154,8 @@ escape_local_throw: {
|
|||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
function baz() {
|
function baz() {
|
||||||
// TODO: improve to match `master`
|
|
||||||
function foo() {}
|
|
||||||
try {
|
try {
|
||||||
throw foo;
|
throw function() {};
|
||||||
} catch (bar) {
|
} catch (bar) {
|
||||||
return bar;
|
return bar;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user