diff --git a/lib/parse.js b/lib/parse.js index 9404e867ebf..5ecf5326b2f 100644 --- a/lib/parse.js +++ b/lib/parse.js @@ -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; } diff --git a/test/compress/arrows.js b/test/compress/arrows.js index 9691648e571..b0c820b3960 100644 --- a/test/compress/arrows.js +++ b/test/compress/arrows.js @@ -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" +}