tw.loop_ids[d.id] = tw.in_loop;
d.fixed = fixed;
d.fixed.assigns = [ node ];
- if (name instanceof AST_SymbolConst && d.redefined()) d.single_use = false;
+ if (name instanceof AST_SymbolConst && d.redefined()
+ || !(can_drop_symbol(name) || is_safe_lexical(d))) {
+ d.single_use = false;
+ }
} else {
d.fixed = false;
}
return;
}
var sym = def.name.definition();
- var drop_sym = !is_var || can_drop_symbol(def.name);
+ var drop_sym = is_var ? can_drop_symbol(def.name) : is_safe_lexical(sym);
if (!drop_sym || !drop_vars || sym.id in in_use_ids) {
if (def.value && indexOf_assign(sym, def) < 0) {
var write_only = def.value.write_only;
}
expect_stdout: true
}
+
+issue_4305_1: {
+ options = {
+ reduce_vars: true,
+ unused: true,
+ }
+ input: {
+ (function() {
+ const arguments = function() {
+ while (console.log("PASS"));
+ };
+ arguments();
+ })();
+ }
+ expect: {
+ (function() {
+ const arguments = function() {
+ while (console.log("PASS"));
+ };
+ arguments();
+ })();
+ }
+ expect_stdout: true
+}
+
+issue_4305_2: {
+ options = {
+ reduce_vars: true,
+ unused: true,
+ }
+ input: {
+ (function(a) {
+ const a = function() {
+ while (console.log("aaaaa"));
+ };
+ a();
+ })();
+ }
+ expect: {
+ (function(a) {
+ const a = function() {
+ while (console.log("aaaaa"));
+ };
+ a();
+ })();
+ }
+ expect_stdout: true
+}
expect_stdout: "PASS"
node_version: ">=4"
}
+
+issue_4305_1: {
+ options = {
+ reduce_vars: true,
+ unused: true,
+ }
+ input: {
+ (function() {
+ let arguments = function() {
+ while (console.log("PASS"));
+ };
+ arguments();
+ })();
+ }
+ expect: {
+ (function() {
+ let arguments = function() {
+ while (console.log("PASS"));
+ };
+ arguments();
+ })();
+ }
+ expect_stdout: true
+ node_version: ">=6"
+}
+
+issue_4305_2: {
+ options = {
+ reduce_vars: true,
+ unused: true,
+ }
+ input: {
+ "use strict";
+ (function(a) {
+ let a = function() {
+ while (console.log("aaaaa"));
+ };
+ a();
+ })();
+ }
+ expect: {
+ "use strict";
+ (function(a) {
+ let a = function() {
+ while (console.log("aaaaa"));
+ };
+ a();
+ })();
+ }
+ expect_stdout: true
+ node_version: ">=4"
+}