Closed
Bug 1026027
Opened 11 years ago
Closed 11 years ago
"use strict" after a template string in a Function should not be treated as a "use strict" directive
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
DUPLICATE
of bug 1024748
People
(Reporter: gupta.rajagopal, Unassigned)
Details
Attachments
(1 file)
1.20 KB,
patch
|
jorendorff
:
review+
|
Details | Diff | Splinter Review |
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:31.0) Gecko/20100101 Firefox/31.0 (Beta/Release)
Build ID: 20140610163407
Attachment #8440813 -
Flags: review?(jorendorff)
Comment 2•11 years ago
|
||
Comment on attachment 8440813 [details] [diff] [review]
Patch and test case for proper functioning of directives with template strings
Review of attachment 8440813 [details] [diff] [review]:
-----------------------------------------------------------------
Nice. r=me with these comments fixed.
::: js/src/frontend/FullParseHandler.h
@@ +539,5 @@
> JSAtom *isStringExprStatement(ParseNode *pn, TokenPos *pos) {
> +
> +#ifdef JS_HAS_TEMPLATE_STRINGS
> + if (pn->getKind() == PNK_TEMPLATE_STRING)
> + return nullptr;
Please fix the indentation --- the last two lines here should be four spaces further to the right.
::: js/src/tests/ecma_6/TemplateStrings/noSubstTests.js
@@ +135,5 @@
> assertThrowsInstanceOf(() => JSON.parse('[1, `false`]'), SyntaxError);
>
> syntaxError('({get `name`() { return 10; }});');
> +
> +assertEq(5, eval('Function("`use strict`; return 05;")()'));
Wrapping this in eval() isn't necessary.
Also, please remember to put the expression that's being tested first, and the expected value second:
assertEq(Function("`use strict`; return 05;")(), 5);
Otherwise, if this assertion ever fails in the future, the error message will be confusing.
@@ +136,5 @@
>
> syntaxError('({get `name`() { return 10; }});');
> +
> +assertEq(5, eval('Function("`use strict`; return 05;")()'));
> +assertEq(5, eval('Function("`ignored string`; \\"use strict\\";return 05;")()'));
Same two comments here.
Attachment #8440813 -
Flags: review?(jorendorff) → review+
Status: UNCONFIRMED → RESOLVED
Closed: 11 years ago
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•