&& !(fn.name && fn instanceof AST_Function)
&& (value = can_flatten_body(stat))
&& (exp === fn
- || !recursive_ref(compressor, def = exp.definition) && fn.is_constant_expression(exp.scope))
+ || !recursive_ref(compressor, def = exp.definition()) && fn.is_constant_expression(exp.scope))
&& !fn.contains_this()) {
if (can_substitute_directly()) {
var args = self.args.slice();
args.push(value.clone(true).transform(new TreeTransformer(function(node) {
if (node instanceof AST_SymbolRef) {
var def = node.definition();
- if (fn.variables.get(node.name) !== def) return node;
+ if (fn.variables.get(node.name) !== def) {
+ if (exp !== fn) def.references.push(node);
+ return node;
+ }
var index = resolve_index(def);
var arg = args[index];
if (!arg) return make_node(AST_Undefined, self);
function can_substitute_directly() {
if (compressor.option("inline") <= 1 && fn.argnames.length) return;
- if (fn.variables.size() > fn.argnames.length + 1) return;
+ var var_count = fn.variables.size() - 1;
+ if (var_count > fn.argnames.length) return;
+ var var_names = [];
if (!all(fn.argnames, function(argname) {
+ push_uniq(var_names, argname.name);
return argname.definition().references.length < 2;
})) return;
+ if (var_count > var_names.length) return;
var abort = false;
var begin;
var in_order = [];