mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-27 01:27:30 +09:00
Track strict mode errors in unary deletions correctly when
syntax-parsing.
This commit is contained in:
parent
1f00dc49d4
commit
e92f878a93
2 changed files with 24 additions and 2 deletions
|
|
@ -641,6 +641,17 @@ Parser<ParseHandler>::strictModeError(unsigned errorNumber, ...)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename ParseHandler>
|
||||||
|
bool
|
||||||
|
Parser<ParseHandler>::strictModeErrorAt(uint32_t offset, unsigned errorNumber, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
va_start(args, errorNumber);
|
||||||
|
bool res = reportHelper(ParseStrictError, pc->sc()->strict(), offset, errorNumber, args);
|
||||||
|
va_end(args);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
template <typename ParseHandler>
|
template <typename ParseHandler>
|
||||||
bool
|
bool
|
||||||
Parser<ParseHandler>::reportWithNode(ParseReportKind kind, bool strict, Node pn, unsigned errorNumber, ...)
|
Parser<ParseHandler>::reportWithNode(ParseReportKind kind, bool strict, Node pn, unsigned errorNumber, ...)
|
||||||
|
|
@ -8031,6 +8042,10 @@ Parser<ParseHandler>::unaryExpr(YieldHandling yieldHandling, TripledotHandling t
|
||||||
}
|
}
|
||||||
|
|
||||||
case TOK_DELETE: {
|
case TOK_DELETE: {
|
||||||
|
uint32_t exprOffset;
|
||||||
|
if (!tokenStream.peekOffset(&exprOffset, TokenStream::Operand))
|
||||||
|
return null();
|
||||||
|
|
||||||
Node expr = unaryExpr(yieldHandling, TripledotProhibited);
|
Node expr = unaryExpr(yieldHandling, TripledotProhibited);
|
||||||
if (!expr)
|
if (!expr)
|
||||||
return null();
|
return null();
|
||||||
|
|
@ -8038,9 +8053,9 @@ Parser<ParseHandler>::unaryExpr(YieldHandling yieldHandling, TripledotHandling t
|
||||||
// Per spec, deleting any unary expression is valid -- it simply
|
// Per spec, deleting any unary expression is valid -- it simply
|
||||||
// returns true -- except for one case that is illegal in strict mode.
|
// returns true -- except for one case that is illegal in strict mode.
|
||||||
if (handler.isNameAnyParentheses(expr)) {
|
if (handler.isNameAnyParentheses(expr)) {
|
||||||
bool strict = pc->sc()->strict();
|
if (!strictModeErrorAt(exprOffset, JSMSG_DEPRECATED_DELETE_OPERAND))
|
||||||
if (!reportWithNode(ParseStrictError, strict, expr, JSMSG_DEPRECATED_DELETE_OPERAND))
|
|
||||||
return null();
|
return null();
|
||||||
|
|
||||||
pc->sc()->setBindingsAccessedDynamically();
|
pc->sc()->setBindingsAccessedDynamically();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -922,6 +922,13 @@ class Parser final : private JS::AutoGCRooter, public StrictModeGetter
|
||||||
*/
|
*/
|
||||||
MOZ_MUST_USE bool strictModeError(unsigned errorNumber, ...);
|
MOZ_MUST_USE bool strictModeError(unsigned errorNumber, ...);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Handle a strict mode error at the given offset. Report an error if in
|
||||||
|
* strict mode code, or warn if not, using the given error number and
|
||||||
|
* arguments.
|
||||||
|
*/
|
||||||
|
MOZ_MUST_USE bool strictModeErrorAt(uint32_t offset, unsigned errorNumber, ...);
|
||||||
|
|
||||||
/* Report the given warning at the current offset. */
|
/* Report the given warning at the current offset. */
|
||||||
MOZ_MUST_USE bool warning(unsigned errorNumber, ...);
|
MOZ_MUST_USE bool warning(unsigned errorNumber, ...);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue