Skip to content

Commit

Permalink
parse directives within arrow functions correctly (#5496)
Browse files Browse the repository at this point in the history
fixes #5495
  • Loading branch information
alexlamsl committed Jun 7, 2022
1 parent be53c48 commit 44e5e99
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/parse.js
Expand Up @@ -1347,16 +1347,20 @@ 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 {
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;
Expand All @@ -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;
}

Expand Down
14 changes: 14 additions & 0 deletions test/compress/arrows.js
Expand Up @@ -1106,3 +1106,17 @@ issue_5416: {
expect_stdout: "undefined"
node_version: ">=4"
}

issue_5495: {
input: {
console.log((() => {
"use strict";
return function() {
return this;
}();
})());
}
expect_exact: 'console.log((()=>{"use strict";return function(){return this}()})());'
expect_stdout: "undefined"
node_version: ">=4"
}

0 comments on commit 44e5e99

Please sign in to comment.