Fix uses_with/uses_eval/directives state in block scope
This commit is contained in:
@@ -119,6 +119,11 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options){
|
||||
scope.init_scope_vars(nesting);
|
||||
scope.parent_scope = save_scope;
|
||||
scope.is_block_scope = true;
|
||||
if (!(node instanceof AST_Scope)) {
|
||||
scope.uses_with = save_scope.uses_with;
|
||||
scope.uses_eval = save_scope.uses_eval;
|
||||
scope.directives = save_scope.directives;
|
||||
}
|
||||
descend();
|
||||
scope = save_scope;
|
||||
return true;
|
||||
|
||||
@@ -13,4 +13,11 @@ describe("With", function() {
|
||||
}
|
||||
assert.throws(test, error);
|
||||
});
|
||||
it("Should set uses_with for scopes involving With statements", function() {
|
||||
var ast = uglify.parse("with(e) {f(1, 2)}");
|
||||
ast.figure_out_scope();
|
||||
assert.equal(ast.uses_with, true);
|
||||
assert.equal(ast.body[0].expression.scope.uses_with, true);
|
||||
assert.equal(ast.body[0].body.body[0].body.expression.scope.uses_with, true);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user