зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1254335 - Remove invalid assertion; r=jorendorff
The underlying intent of the assertion was to guarantee that pending errors wouldn't be overwritten. This patch makes that intent more clear while addressing the fact that the original assertion was not necessarily true. --HG-- extra : rebase_source : f57ea76a10faed4470186dc3869c4dcf19b1608b
This commit is contained in:
Родитель
5a9c81f6df
Коммит
b5acf52487
|
@ -3945,10 +3945,13 @@ Parser<ParseHandler>::PossibleError::PossibleError(Parser<ParseHandler>& parser)
|
|||
}
|
||||
|
||||
template <typename ParseHandler>
|
||||
void
|
||||
bool
|
||||
Parser<ParseHandler>::PossibleError::setPending(ParseReportKind kind, unsigned errorNumber,
|
||||
bool strict)
|
||||
{
|
||||
if (hasError())
|
||||
return false;
|
||||
|
||||
// If we report an error later, we'll do it from the position where we set
|
||||
// the state to pending.
|
||||
offset_ = parser_.pos().begin;
|
||||
|
@ -3956,6 +3959,8 @@ Parser<ParseHandler>::PossibleError::setPending(ParseReportKind kind, unsigned e
|
|||
strict_ = strict;
|
||||
errorNumber_ = errorNumber;
|
||||
state_ = ErrorState::Pending;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename ParseHandler>
|
||||
|
@ -3977,9 +3982,8 @@ bool
|
|||
Parser<ParseHandler>::PossibleError::checkForExprErrors()
|
||||
{
|
||||
bool err = hasError();
|
||||
if (err) {
|
||||
if (err)
|
||||
parser_.reportWithOffset(reportKind_, strict_, offset_, errorNumber_);
|
||||
}
|
||||
return !err;
|
||||
}
|
||||
|
||||
|
@ -7828,7 +7832,6 @@ Parser<ParseHandler>::assignExpr(InHandling inHandling, YieldHandling yieldHandl
|
|||
InvokedPrediction invoked)
|
||||
{
|
||||
JS_CHECK_RECURSION(context, return null());
|
||||
MOZ_ASSERT(!possibleError->hasError());
|
||||
|
||||
// It's very common at this point to have a "detectably simple" expression,
|
||||
// i.e. a name/number/string token followed by one of the following tokens
|
||||
|
@ -9310,8 +9313,13 @@ Parser<ParseHandler>::objectLiteral(YieldHandling yieldHandling, PossibleError*
|
|||
// valid in the case of destructuring. Here we set a pending error so
|
||||
// that later in the parse, once we've determined whether or not we're
|
||||
// destructuring, the error can be reported or ignored appropriately.
|
||||
if (possibleError)
|
||||
possibleError->setPending(ParseError, JSMSG_BAD_PROP_ID, false);
|
||||
if (possibleError &&
|
||||
!possibleError->setPending(ParseError, JSMSG_BAD_PROP_ID, false)) {
|
||||
|
||||
// Report any previously pending error.
|
||||
possibleError->checkForExprErrors();
|
||||
return null();
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
|
|
@ -462,8 +462,9 @@ class Parser : private JS::AutoGCRooter, public StrictModeGetter
|
|||
public:
|
||||
explicit PossibleError(Parser<ParseHandler>& parser);
|
||||
|
||||
// Set a pending error.
|
||||
void setPending(ParseReportKind kind, unsigned errorNumber, bool strict);
|
||||
// Set a pending error. Only a single error may be set per instance.
|
||||
// Returns true on success or false on failure.
|
||||
bool setPending(ParseReportKind kind, unsigned errorNumber, bool strict);
|
||||
|
||||
// Resolve any pending error.
|
||||
void setResolved();
|
||||
|
|
|
@ -19,6 +19,7 @@ const SYNTAX_ERROR_STMTS = [
|
|||
"({z={x=1}})=>{};",
|
||||
"({x = ({y=1}) => y})",
|
||||
"(({x=1})) => x",
|
||||
"({e=[]}==(;",
|
||||
// declarations
|
||||
"let o = {x=1};",
|
||||
"var j = {x=1};",
|
||||
|
|
Загрузка…
Ссылка в новой задаче