} : function(node) {
return node instanceof AST_Await && !tw.find_parent(AST_Scope);
};
- var tw = new TreeWalker(function(node) {
+ var arg_scope = null;
+ var tw = new TreeWalker(function(node, descend) {
if (!arg) return true;
if (has_await(node) || node instanceof AST_Yield) {
arg = null;
return true;
}
+ if (node instanceof AST_ObjectIdentity && (fn_strict || !arg_scope)) {
+ arg = null;
+ return true;
+ }
if (node instanceof AST_SymbolRef && fn.variables.has(node.name)) {
var s = node.definition().scope;
if (s !== scope) while (s = s.parent_scope) {
}
arg = null;
}
- if (node instanceof AST_ObjectIdentity && (fn_strict
- || !tw.find_parent(AST_Scope)
- || is_arrow(arg) && iife instanceof AST_New)) {
- arg = null;
+ if (node instanceof AST_Scope && !is_arrow(node)) {
+ var save_scope = arg_scope;
+ arg_scope = node;
+ descend();
+ arg_scope = save_scope;
return true;
}
});
// determine if expression is constant
(function(def) {
- function all(list) {
+ function all_constant(list) {
for (var i = list.length; --i >= 0;)
if (!list[i].is_constant_expression())
return false;
}
def(AST_Node, return_false);
def(AST_Array, function() {
- return all(this.elements);
+ return all_constant(this.elements);
});
def(AST_Binary, function() {
return this.left.is_constant_expression()
&& (this.operator != "in" || is_object(this.right));
});
def(AST_Class, function() {
- return !this.extends && all(this.properties);
+ return !this.extends && all_constant(this.properties);
});
def(AST_ClassProperty, function() {
return typeof this.key == "string" && (!this.value || this.value.is_constant_expression());
return true;
}
if (node instanceof AST_ObjectIdentity) {
- if (scopes.length == 0 && is_arrow(self)) result = false;
+ if (is_arrow(self) && all(scopes, function(s) {
+ return !(s instanceof AST_Scope) || is_arrow(s);
+ })) result = false;
return true;
}
}));
return result;
});
def(AST_Object, function() {
- return all(this.properties);
+ return all_constant(this.properties);
});
def(AST_ObjectProperty, function() {
return typeof this.key == "string" && this.value.is_constant_expression();