parse directives within arrow functions correctly (#5496)

fixes #5495
This commit is contained in:
Alex Lam S.L
2022-06-07 03:33:17 +01:00
committed by GitHub
parent be53c4838b
commit 44e5e99aae
2 changed files with 19 additions and 1 deletions

View File

@@ -1347,9 +1347,11 @@ function parse($TEXT, options) {
var loop = S.in_loop;
var labels = S.labels;
++S.in_function;
S.input.push_directives_stack();
S.in_loop = 0;
S.labels = [];
if (is("punc", "{")) {
S.in_directives = true;
body = block_();
value = null;
} else {
@@ -1357,6 +1359,8 @@ function parse($TEXT, options) {
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;
@@ -1370,7 +1374,7 @@ function parse($TEXT, options) {
value: value,
end: prev(),
});
if (S.input.has_directive("use strict")) node.each_argname(strict_verify_symbol);
if (is_strict) node.each_argname(strict_verify_symbol);
return node;
}