Specify an explicit offset when warning about "use asm" found in the

directive prologue of a script (rather than a function body).
This commit is contained in:
wolfbeast 2019-04-05 21:30:52 +02:00 committed by Roy Tam
commit 1f00dc49d4
3 changed files with 7 additions and 6 deletions

View file

@ -3811,10 +3811,10 @@ Parser<FullParseHandler>::asmJS(Node list)
*/
template <typename ParseHandler>
bool
Parser<ParseHandler>::maybeParseDirective(Node list, Node pn, bool* cont)
Parser<ParseHandler>::maybeParseDirective(Node list, Node possibleDirective, bool* cont)
{
TokenPos directivePos;
JSAtom* directive = handler.isStringExprStatement(pn, &directivePos);
JSAtom* directive = handler.isStringExprStatement(possibleDirective, &directivePos);
*cont = !!directive;
if (!*cont)
@ -3831,7 +3831,7 @@ Parser<ParseHandler>::maybeParseDirective(Node list, Node pn, bool* cont)
// directive in the future. We don't want to interfere with people
// taking advantage of directive-prologue-enabled features that appear
// in other browsers first.
handler.setPrologue(pn);
handler.setInDirectivePrologue(possibleDirective);
if (directive == context->names().useStrict) {
// Functions with non-simple parameter lists (destructuring,
@ -3867,7 +3867,8 @@ Parser<ParseHandler>::maybeParseDirective(Node list, Node pn, bool* cont)
} else if (directive == context->names().useAsm) {
if (pc->isFunctionBox())
return asmJS(list);
return reportWithNode(ParseWarning, false, pn, JSMSG_USE_ASM_DIRECTIVE_FAIL);
return reportWithOffset(ParseWarning, false, directivePos.begin,
JSMSG_USE_ASM_DIRECTIVE_FAIL);
}
}
return true;