fix corner cases in parse & unused (#5000)

This commit is contained in:
Alex Lam S.L
2021-06-12 17:10:01 +01:00
committed by GitHub
parent 70ceda5398
commit f8b2215145
5 changed files with 42 additions and 43 deletions

View File

@@ -1334,21 +1334,19 @@ function parse($TEXT, options) {
if (is("punc", "{")) {
body = block_();
value = null;
if (S.input.has_directive("use strict")) {
argnames.forEach(strict_verify_symbol);
}
} else {
body = [];
handle_regexp();
value = maybe_assign();
}
var is_strict = S.input.has_directive("use strict");
S.input.pop_directives_stack();
--S.in_function;
S.in_loop = loop;
S.labels = labels;
S.in_generator = was_gen;
S.in_async = was_async;
return new (async ? AST_AsyncArrow : AST_Arrow)({
var node = new (async ? AST_AsyncArrow : AST_Arrow)({
start: start,
argnames: argnames,
rest: rest,
@@ -1356,6 +1354,8 @@ function parse($TEXT, options) {
value: value,
end: prev(),
});
if (is_strict) node.each_argname(strict_verify_symbol);
return node;
}
var function_ = function(ctor) {
@@ -1388,23 +1388,24 @@ function parse($TEXT, options) {
S.in_loop = 0;
S.labels = [];
var body = block_();
if (S.input.has_directive("use strict")) {
if (name) strict_verify_symbol(name);
argnames.forEach(strict_verify_symbol);
if (argnames.rest) strict_verify_symbol(argnames.rest);
}
var is_strict = S.input.has_directive("use strict");
S.input.pop_directives_stack();
--S.in_function;
S.in_loop = loop;
S.labels = labels;
S.in_generator = was_gen;
S.in_async = was_async;
return new ctor({
var node = new ctor({
name: name,
argnames: argnames,
rest: argnames.rest || null,
body: body
});
if (is_strict) {
if (name) strict_verify_symbol(name);
node.each_argname(strict_verify_symbol);
}
return node;
};
function if_() {