&& !fn.uses_eval
&& (iife = compressor.parent()) instanceof AST_Call
&& iife.expression === fn) {
- fn.argnames.forEach(function(sym, i) {
+ var names = Object.create(null);
+ for (var i = fn.argnames.length; --i >= 0;) {
+ var sym = fn.argnames[i];
+ if (sym.name in names) continue;
+ names[sym.name] = true;
var arg = iife.args[i];
if (!arg) arg = make_node(AST_Undefined, sym);
else {
});
arg.walk(tw);
}
- if (arg) candidates.push(make_node(AST_VarDef, sym, {
+ if (arg) candidates.unshift(make_node(AST_VarDef, sym, {
name: sym,
value: arg
}));
- });
+ }
}
}
}
expect_stdout: "PASS"
}
+
+duplicate_argname: {
+ options = {
+ collapse_vars: true,
+ unused: true,
+ }
+ input: {
+ function f() { return "PASS"; }
+ console.log(function(a, a) {
+ f++;
+ return a;
+ }("FAIL", f()));
+ }
+ expect: {
+ function f() { return "PASS"; }
+ console.log(function(a, a) {
+ f++;
+ return a;
+ }("FAIL", f()));
+ }
+ expect_stdout: "PASS"
+}