fixed.name = make_node(AST_SymbolLambda, fixed.name, fixed.name);
}
if (fixed instanceof AST_Lambda) {
- var scope = self.scope;
+ var scope = self.scope.resolve();
fixed.enclosed.forEach(function(def) {
if (fixed.variables.has(def.name)) return;
if (scope.var_names()[def.name]) return;
}
}
- var statement = embed_tokens(function(strict_defun) {
+ var statement = embed_tokens(function() {
handle_regexp();
switch (S.token.type) {
case "string":
return for_();
case "function":
- if (!strict_defun && S.input.has_directive("use strict")) {
- croak("In strict mode code, functions can only be declared at top level or immediately within another function.");
- }
next();
return function_(AST_Defun);
S.input.push_directives_stack();
S.in_loop = 0;
S.labels = [];
- var body = block_(true);
+ var body = block_();
if (S.input.has_directive("use strict")) {
if (name) strict_verify_symbol(name);
argnames.forEach(strict_verify_symbol);
});
}
- function block_(strict_defun) {
+ function block_() {
expect("{");
var a = [];
while (!is("punc", "}")) {
if (is("eof")) expect_token("punc", "}");
- a.push(statement(strict_defun));
+ a.push(statement());
}
next();
return a;
var body = [];
S.input.push_directives_stack();
while (!is("eof"))
- body.push(statement(true));
+ body.push(statement());
S.input.pop_directives_stack();
var end = prev();
var toplevel = options.toplevel;
var b = 1;
do {
3[b];
- } while(0);
+ } while (0);
console.log(b);
}
expect_stdout: "1"
do {
a = 3,
a[b];
- } while(0);
+ } while (0);
var a;
console.log(b);
}
do {
a = 3,
a[b];
- } while(0);
+ } while (0);
var a;
console.log(b);
}
var b = 1;
do {
console.log((a = void 0, a ? "FAIL" : a = "PASS"));
- } while(b--);
+ } while (b--);
var a;
}
expect_stdout: [
var b = 1;
do {
console.log((a = void 0, a ? "FAIL" : a = "PASS"));
- } while(b--);
+ } while (b--);
var a;
}
expect_stdout: [
}
expect_stdout: "function"
}
+
+issue_4261: {
+ options = {
+ inline: true,
+ reduce_funcs: true,
+ reduce_vars: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ try {
+ throw 42;
+ } catch (e) {
+ (function() {
+ function f() {
+ e.p;
+ }
+ function g() {
+ while (f());
+ }
+ (function() {
+ while (console.log(g()));
+ })();
+ })();
+ }
+ }
+ expect: {
+ try {
+ throw 42;
+ } catch (e) {
+ (function() {
+ function g() {
+ while (void e.p);
+ }
+ (function() {
+ while (console.log(g()));
+ })();
+ })();
+ }
+ }
+ expect_stdout: true
+}