mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-21 22:57:31 +09:00
Change report at current offset to warning(), extraWarning() and error()
This commit is contained in:
parent
70fbb46d9e
commit
a652eb1916
2 changed files with 152 additions and 122 deletions
|
|
@ -63,13 +63,13 @@ using BindingIter = ParseContext::Scope::BindingIter;
|
||||||
using UsedNamePtr = UsedNameTracker::UsedNameMap::Ptr;
|
using UsedNamePtr = UsedNameTracker::UsedNameMap::Ptr;
|
||||||
|
|
||||||
/* Read a token. Report an error and return null() if that token isn't of type tt. */
|
/* Read a token. Report an error and return null() if that token isn't of type tt. */
|
||||||
#define MUST_MATCH_TOKEN_MOD(tt, modifier, errno) \
|
#define MUST_MATCH_TOKEN_MOD(tt, modifier, errorNumber) \
|
||||||
JS_BEGIN_MACRO \
|
JS_BEGIN_MACRO \
|
||||||
TokenKind token; \
|
TokenKind token; \
|
||||||
if (!tokenStream.getToken(&token, modifier)) \
|
if (!tokenStream.getToken(&token, modifier)) \
|
||||||
return null(); \
|
return null(); \
|
||||||
if (token != tt) { \
|
if (token != tt) { \
|
||||||
qeport(ParseError, errno); \
|
error(errorNumber); \
|
||||||
return null(); \
|
return null(); \
|
||||||
} \
|
} \
|
||||||
JS_END_MACRO
|
JS_END_MACRO
|
||||||
|
|
@ -595,12 +595,37 @@ Parser<ParseHandler>::reportHelper(ParseReportKind kind, bool strict, uint32_t o
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename ParseHandler>
|
template <typename ParseHandler>
|
||||||
bool
|
void
|
||||||
Parser<ParseHandler>::qeport(ParseReportKind kind, unsigned errorNumber, ...)
|
Parser<ParseHandler>::error(unsigned errorNumber, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, errorNumber);
|
va_start(args, errorNumber);
|
||||||
bool result = reportHelper(kind, false, pos().begin, errorNumber, args);
|
#ifdef DEBUG
|
||||||
|
bool result =
|
||||||
|
#endif
|
||||||
|
reportHelper(ParseError, false, pos().begin, errorNumber, args);
|
||||||
|
MOZ_ASSERT(!result, "reporting an error returned true?");
|
||||||
|
va_end(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename ParseHandler>
|
||||||
|
bool
|
||||||
|
Parser<ParseHandler>::warning(unsigned errorNumber, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
va_start(args, errorNumber);
|
||||||
|
bool result = reportHelper(ParseWarning, false, pos().begin, errorNumber, args);
|
||||||
|
va_end(args);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename ParseHandler>
|
||||||
|
bool
|
||||||
|
Parser<ParseHandler>::extraWarning(unsigned errorNumber, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
va_start(args, errorNumber);
|
||||||
|
bool result = reportHelper(ParseExtraWarning, false, pos().begin, errorNumber, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -848,7 +873,7 @@ Parser<ParseHandler>::parse()
|
||||||
if (!tokenStream.getToken(&tt, TokenStream::Operand))
|
if (!tokenStream.getToken(&tt, TokenStream::Operand))
|
||||||
return null();
|
return null();
|
||||||
if (tt != TOK_EOF) {
|
if (tt != TOK_EOF) {
|
||||||
qeport(ParseError, JSMSG_GARBAGE_AFTER_INPUT, "script", TokenKindToDesc(tt));
|
error(JSMSG_GARBAGE_AFTER_INPUT, "script", TokenKindToDesc(tt));
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
if (foldConstants) {
|
if (foldConstants) {
|
||||||
|
|
@ -962,7 +987,7 @@ Parser<ParseHandler>::notePositionalFormalParameter(Node fn, HandlePropertyName
|
||||||
{
|
{
|
||||||
if (AddDeclaredNamePtr p = pc->functionScope().lookupDeclaredNameForAdd(name)) {
|
if (AddDeclaredNamePtr p = pc->functionScope().lookupDeclaredNameForAdd(name)) {
|
||||||
if (disallowDuplicateParams) {
|
if (disallowDuplicateParams) {
|
||||||
qeport(ParseError, JSMSG_BAD_DUP_ARGS);
|
error(JSMSG_BAD_DUP_ARGS);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1257,7 +1282,7 @@ Parser<ParseHandler>::noteDeclaredName(HandlePropertyName name, DeclarationKind
|
||||||
|
|
||||||
AddDeclaredNamePtr p = pc->functionScope().lookupDeclaredNameForAdd(name);
|
AddDeclaredNamePtr p = pc->functionScope().lookupDeclaredNameForAdd(name);
|
||||||
if (p) {
|
if (p) {
|
||||||
qeport(ParseError, JSMSG_BAD_DUP_ARGS);
|
error(JSMSG_BAD_DUP_ARGS);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1464,7 +1489,7 @@ Parser<FullParseHandler>::checkStatementsEOF()
|
||||||
if (!tokenStream.peekToken(&tt, TokenStream::Operand))
|
if (!tokenStream.peekToken(&tt, TokenStream::Operand))
|
||||||
return false;
|
return false;
|
||||||
if (tt != TOK_EOF) {
|
if (tt != TOK_EOF) {
|
||||||
qeport(ParseError, JSMSG_UNEXPECTED_TOKEN, "expression", TokenKindToDesc(tt));
|
error(JSMSG_UNEXPECTED_TOKEN, "expression", TokenKindToDesc(tt));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -1929,7 +1954,7 @@ Parser<FullParseHandler>::evalBody(EvalSharedContext* evalsc)
|
||||||
// script.
|
// script.
|
||||||
if (hasUsedName(context->names().arguments)) {
|
if (hasUsedName(context->names().arguments)) {
|
||||||
if (IsArgumentsUsedInLegacyGenerator(context, pc->sc()->compilationEnclosingScope())) {
|
if (IsArgumentsUsedInLegacyGenerator(context, pc->sc()->compilationEnclosingScope())) {
|
||||||
qeport(ParseError, JSMSG_BAD_GENEXP_BODY, js_arguments_str);
|
error(JSMSG_BAD_GENEXP_BODY, js_arguments_str);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2027,7 +2052,7 @@ Parser<FullParseHandler>::moduleBody(ModuleSharedContext* modulesc)
|
||||||
if (!tokenStream.getToken(&tt, TokenStream::Operand))
|
if (!tokenStream.getToken(&tt, TokenStream::Operand))
|
||||||
return null();
|
return null();
|
||||||
if (tt != TOK_EOF) {
|
if (tt != TOK_EOF) {
|
||||||
qeport(ParseError, JSMSG_GARBAGE_AFTER_INPUT, "module", TokenKindToDesc(tt));
|
error(JSMSG_GARBAGE_AFTER_INPUT, "module", TokenKindToDesc(tt));
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2347,7 +2372,7 @@ Parser<FullParseHandler>::standaloneFunction(HandleFunction fun,
|
||||||
if (!tokenStream.getToken(&tt, TokenStream::Operand))
|
if (!tokenStream.getToken(&tt, TokenStream::Operand))
|
||||||
return null();
|
return null();
|
||||||
if (tt != TOK_EOF) {
|
if (tt != TOK_EOF) {
|
||||||
qeport(ParseError, JSMSG_GARBAGE_AFTER_INPUT, "function body", TokenKindToDesc(tt));
|
error(JSMSG_GARBAGE_AFTER_INPUT, "function body", TokenKindToDesc(tt));
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2752,7 +2777,7 @@ Parser<ParseHandler>::functionArguments(YieldHandling yieldHandling, FunctionSyn
|
||||||
if (!tokenStream.getToken(&tt, firstTokenModifier))
|
if (!tokenStream.getToken(&tt, firstTokenModifier))
|
||||||
return false;
|
return false;
|
||||||
if (tt != TOK_LP) {
|
if (tt != TOK_LP) {
|
||||||
qeport(ParseError, kind == Arrow ? JSMSG_BAD_ARROW_ARGS : JSMSG_PAREN_BEFORE_FORMAL);
|
error(kind == Arrow ? JSMSG_BAD_ARROW_ARGS : JSMSG_PAREN_BEFORE_FORMAL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2784,13 +2809,13 @@ Parser<ParseHandler>::functionArguments(YieldHandling yieldHandling, FunctionSyn
|
||||||
AtomVector& positionalFormals = pc->positionalFormalParameterNames();
|
AtomVector& positionalFormals = pc->positionalFormalParameterNames();
|
||||||
|
|
||||||
if (IsGetterKind(kind)) {
|
if (IsGetterKind(kind)) {
|
||||||
qeport(ParseError, JSMSG_ACCESSOR_WRONG_ARGS, "getter", "no", "s");
|
error(JSMSG_ACCESSOR_WRONG_ARGS, "getter", "no", "s");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if (hasRest) {
|
if (hasRest) {
|
||||||
qeport(ParseError, JSMSG_PARAMETER_AFTER_REST);
|
error(JSMSG_PARAMETER_AFTER_REST);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2802,14 +2827,14 @@ Parser<ParseHandler>::functionArguments(YieldHandling yieldHandling, FunctionSyn
|
||||||
|
|
||||||
if (tt == TOK_TRIPLEDOT) {
|
if (tt == TOK_TRIPLEDOT) {
|
||||||
if (IsSetterKind(kind)) {
|
if (IsSetterKind(kind)) {
|
||||||
qeport(ParseError, JSMSG_ACCESSOR_WRONG_ARGS, "setter", "one", "");
|
error(JSMSG_ACCESSOR_WRONG_ARGS, "setter", "one", "");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
disallowDuplicateParams = true;
|
disallowDuplicateParams = true;
|
||||||
if (duplicatedParam) {
|
if (duplicatedParam) {
|
||||||
// Has duplicated args before the rest parameter.
|
// Has duplicated args before the rest parameter.
|
||||||
qeport(ParseError, JSMSG_BAD_DUP_ARGS);
|
error(JSMSG_BAD_DUP_ARGS);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2820,7 +2845,7 @@ Parser<ParseHandler>::functionArguments(YieldHandling yieldHandling, FunctionSyn
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (tt != TOK_NAME && tt != TOK_YIELD && tt != TOK_LB && tt != TOK_LC) {
|
if (tt != TOK_NAME && tt != TOK_YIELD && tt != TOK_LB && tt != TOK_LC) {
|
||||||
qeport(ParseError, JSMSG_NO_REST_NAME);
|
error(JSMSG_NO_REST_NAME);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2831,7 +2856,7 @@ Parser<ParseHandler>::functionArguments(YieldHandling yieldHandling, FunctionSyn
|
||||||
disallowDuplicateParams = true;
|
disallowDuplicateParams = true;
|
||||||
if (duplicatedParam) {
|
if (duplicatedParam) {
|
||||||
// Has duplicated args before the destructuring parameter.
|
// Has duplicated args before the destructuring parameter.
|
||||||
qeport(ParseError, JSMSG_BAD_DUP_ARGS);
|
error(JSMSG_BAD_DUP_ARGS);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2859,7 +2884,7 @@ Parser<ParseHandler>::functionArguments(YieldHandling yieldHandling, FunctionSyn
|
||||||
// case:
|
// case:
|
||||||
//
|
//
|
||||||
// async await => 1
|
// async await => 1
|
||||||
qeport(ParseError, JSMSG_RESERVED_ID, "await");
|
error(JSMSG_RESERVED_ID, "await");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2879,12 +2904,12 @@ Parser<ParseHandler>::functionArguments(YieldHandling yieldHandling, FunctionSyn
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
qeport(ParseError, JSMSG_MISSING_FORMAL);
|
error(JSMSG_MISSING_FORMAL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (positionalFormals.length() >= ARGNO_LIMIT) {
|
if (positionalFormals.length() >= ARGNO_LIMIT) {
|
||||||
qeport(ParseError, JSMSG_TOO_MANY_FUN_ARGS);
|
error(JSMSG_TOO_MANY_FUN_ARGS);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2899,12 +2924,12 @@ Parser<ParseHandler>::functionArguments(YieldHandling yieldHandling, FunctionSyn
|
||||||
MOZ_ASSERT(!parenFreeArrow);
|
MOZ_ASSERT(!parenFreeArrow);
|
||||||
|
|
||||||
if (hasRest) {
|
if (hasRest) {
|
||||||
qeport(ParseError, JSMSG_REST_WITH_DEFAULT);
|
error(JSMSG_REST_WITH_DEFAULT);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
disallowDuplicateParams = true;
|
disallowDuplicateParams = true;
|
||||||
if (duplicatedParam) {
|
if (duplicatedParam) {
|
||||||
qeport(ParseError, JSMSG_BAD_DUP_ARGS);
|
error(JSMSG_BAD_DUP_ARGS);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2948,11 +2973,11 @@ Parser<ParseHandler>::functionArguments(YieldHandling yieldHandling, FunctionSyn
|
||||||
return false;
|
return false;
|
||||||
if (tt != TOK_RP) {
|
if (tt != TOK_RP) {
|
||||||
if (IsSetterKind(kind)) {
|
if (IsSetterKind(kind)) {
|
||||||
qeport(ParseError, JSMSG_ACCESSOR_WRONG_ARGS, "setter", "one", "");
|
error(JSMSG_ACCESSOR_WRONG_ARGS, "setter", "one", "");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
qeport(ParseError, JSMSG_PAREN_AFTER_FORMAL);
|
error(JSMSG_PAREN_AFTER_FORMAL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2965,7 +2990,7 @@ Parser<ParseHandler>::functionArguments(YieldHandling yieldHandling, FunctionSyn
|
||||||
|
|
||||||
funbox->function()->setArgCount(positionalFormals.length());
|
funbox->function()->setArgCount(positionalFormals.length());
|
||||||
} else if (IsSetterKind(kind)) {
|
} else if (IsSetterKind(kind)) {
|
||||||
qeport(ParseError, JSMSG_ACCESSOR_WRONG_ARGS, "setter", "one", "");
|
error(JSMSG_ACCESSOR_WRONG_ARGS, "setter", "one", "");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3095,7 +3120,7 @@ Parser<ParseHandler>::addExprAndGetNextTemplStrToken(YieldHandling yieldHandling
|
||||||
if (!tokenStream.getToken(&tt))
|
if (!tokenStream.getToken(&tt))
|
||||||
return false;
|
return false;
|
||||||
if (tt != TOK_RC) {
|
if (tt != TOK_RC) {
|
||||||
qeport(ParseError, JSMSG_TEMPLSTR_UNTERM_EXPR);
|
error(JSMSG_TEMPLSTR_UNTERM_EXPR);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3487,7 +3512,7 @@ Parser<ParseHandler>::functionFormalParametersAndBody(InHandling inHandling,
|
||||||
if (!tokenStream.matchToken(&matched, TOK_ARROW))
|
if (!tokenStream.matchToken(&matched, TOK_ARROW))
|
||||||
return false;
|
return false;
|
||||||
if (!matched) {
|
if (!matched) {
|
||||||
qeport(ParseError, JSMSG_BAD_ARROW_ARGS);
|
error(JSMSG_BAD_ARROW_ARGS);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -3495,7 +3520,7 @@ Parser<ParseHandler>::functionFormalParametersAndBody(InHandling inHandling,
|
||||||
// When parsing something for new Function() we have to make sure to
|
// When parsing something for new Function() we have to make sure to
|
||||||
// only treat a certain part of the source as a parameter list.
|
// only treat a certain part of the source as a parameter list.
|
||||||
if (parameterListEnd.isSome() && parameterListEnd.value() != pos().begin) {
|
if (parameterListEnd.isSome() && parameterListEnd.value() != pos().begin) {
|
||||||
qeport(ParseError, JSMSG_UNEXPECTED_PARAMLIST_END);
|
error(JSMSG_UNEXPECTED_PARAMLIST_END);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3508,7 +3533,7 @@ Parser<ParseHandler>::functionFormalParametersAndBody(InHandling inHandling,
|
||||||
if ((funbox->isStarGenerator() && !funbox->isAsync()) || kind == Method ||
|
if ((funbox->isStarGenerator() && !funbox->isAsync()) || kind == Method ||
|
||||||
kind == GetterNoExpressionClosure || kind == SetterNoExpressionClosure ||
|
kind == GetterNoExpressionClosure || kind == SetterNoExpressionClosure ||
|
||||||
IsConstructorKind(kind)) {
|
IsConstructorKind(kind)) {
|
||||||
qeport(ParseError, JSMSG_CURLY_BEFORE_BODY);
|
error(JSMSG_CURLY_BEFORE_BODY);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3517,7 +3542,7 @@ Parser<ParseHandler>::functionFormalParametersAndBody(InHandling inHandling,
|
||||||
if (!warnOnceAboutExprClosure())
|
if (!warnOnceAboutExprClosure())
|
||||||
return false;
|
return false;
|
||||||
#else
|
#else
|
||||||
qeport(ParseError, JSMSG_CURLY_BEFORE_BODY);
|
error(JSMSG_CURLY_BEFORE_BODY);
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
@ -3550,7 +3575,7 @@ Parser<ParseHandler>::functionFormalParametersAndBody(InHandling inHandling,
|
||||||
if (!tokenStream.matchToken(&matched, TOK_RC, TokenStream::Operand))
|
if (!tokenStream.matchToken(&matched, TOK_RC, TokenStream::Operand))
|
||||||
return false;
|
return false;
|
||||||
if (!matched) {
|
if (!matched) {
|
||||||
qeport(ParseError, JSMSG_CURLY_AFTER_BODY);
|
error(JSMSG_CURLY_AFTER_BODY);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
funbox->bufEnd = pos().end;
|
funbox->bufEnd = pos().end;
|
||||||
|
|
@ -3608,7 +3633,7 @@ Parser<ParseHandler>::functionStmt(uint32_t preludeStart, YieldHandling yieldHan
|
||||||
|
|
||||||
if (tt == TOK_MUL) {
|
if (tt == TOK_MUL) {
|
||||||
if (asyncKind != SyncFunction) {
|
if (asyncKind != SyncFunction) {
|
||||||
qeport(ParseError, JSMSG_ASYNC_GENERATOR);
|
error(JSMSG_ASYNC_GENERATOR);
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
generatorKind = StarGenerator;
|
generatorKind = StarGenerator;
|
||||||
|
|
@ -3625,7 +3650,7 @@ Parser<ParseHandler>::functionStmt(uint32_t preludeStart, YieldHandling yieldHan
|
||||||
tokenStream.ungetToken();
|
tokenStream.ungetToken();
|
||||||
} else {
|
} else {
|
||||||
/* Unnamed function expressions are forbidden in statement context. */
|
/* Unnamed function expressions are forbidden in statement context. */
|
||||||
qeport(ParseError, JSMSG_UNNAMED_FUNCTION_STMT);
|
error(JSMSG_UNNAMED_FUNCTION_STMT);
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3661,7 +3686,7 @@ Parser<ParseHandler>::functionExpr(uint32_t preludeStart, InvokedPrediction invo
|
||||||
|
|
||||||
if (tt == TOK_MUL) {
|
if (tt == TOK_MUL) {
|
||||||
if (asyncKind != SyncFunction) {
|
if (asyncKind != SyncFunction) {
|
||||||
qeport(ParseError, JSMSG_ASYNC_GENERATOR);
|
error(JSMSG_ASYNC_GENERATOR);
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
generatorKind = StarGenerator;
|
generatorKind = StarGenerator;
|
||||||
|
|
@ -3834,7 +3859,7 @@ Parser<ParseHandler>::maybeParseDirective(Node list, Node pn, bool* cont)
|
||||||
// occur in the directive prologue -- octal escapes -- and
|
// occur in the directive prologue -- octal escapes -- and
|
||||||
// complain now.
|
// complain now.
|
||||||
if (tokenStream.sawOctalEscape()) {
|
if (tokenStream.sawOctalEscape()) {
|
||||||
qeport(ParseError, JSMSG_DEPRECATED_OCTAL);
|
error(JSMSG_DEPRECATED_OCTAL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
pc->sc()->strictScript = true;
|
pc->sc()->strictScript = true;
|
||||||
|
|
@ -3921,7 +3946,7 @@ Parser<ParseHandler>::condition(InHandling inHandling, YieldHandling yieldHandli
|
||||||
|
|
||||||
/* Check for (a = b) and warn about possible (a == b) mistype. */
|
/* Check for (a = b) and warn about possible (a == b) mistype. */
|
||||||
if (handler.isUnparenthesizedAssignment(pn)) {
|
if (handler.isUnparenthesizedAssignment(pn)) {
|
||||||
if (!qeport(ParseExtraWarning, JSMSG_EQUAL_AS_ASSIGN))
|
if (!extraWarning(JSMSG_EQUAL_AS_ASSIGN))
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
return pn;
|
return pn;
|
||||||
|
|
@ -4503,7 +4528,7 @@ Parser<ParseHandler>::declarationName(Node decl, DeclarationKind declKind, Token
|
||||||
{
|
{
|
||||||
// Anything other than TOK_YIELD or TOK_NAME is an error.
|
// Anything other than TOK_YIELD or TOK_NAME is an error.
|
||||||
if (tt != TOK_NAME && tt != TOK_YIELD) {
|
if (tt != TOK_NAME && tt != TOK_YIELD) {
|
||||||
qeport(ParseError, JSMSG_NO_VARIABLE_NAME);
|
error(JSMSG_NO_VARIABLE_NAME);
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4703,7 +4728,7 @@ Parser<FullParseHandler>::namedImportsOrNamespaceImport(TokenKind tt, Node impor
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (afterAs != TOK_NAME && afterAs != TOK_YIELD) {
|
if (afterAs != TOK_NAME && afterAs != TOK_YIELD) {
|
||||||
qeport(ParseError, JSMSG_NO_BINDING_NAME);
|
error(JSMSG_NO_BINDING_NAME);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -4715,7 +4740,7 @@ Parser<FullParseHandler>::namedImportsOrNamespaceImport(TokenKind tt, Node impor
|
||||||
JSAutoByteString bytes;
|
JSAutoByteString bytes;
|
||||||
if (!AtomToPrintableString(context, importName, &bytes))
|
if (!AtomToPrintableString(context, importName, &bytes))
|
||||||
return false;
|
return false;
|
||||||
qeport(ParseError, JSMSG_AS_AFTER_RESERVED_WORD, bytes.ptr());
|
error(JSMSG_AS_AFTER_RESERVED_WORD, bytes.ptr());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -4812,7 +4837,7 @@ Parser<FullParseHandler>::importDeclaration()
|
||||||
MOZ_ASSERT(tokenStream.currentToken().type == TOK_IMPORT);
|
MOZ_ASSERT(tokenStream.currentToken().type == TOK_IMPORT);
|
||||||
|
|
||||||
if (!pc->atModuleLevel()) {
|
if (!pc->atModuleLevel()) {
|
||||||
qeport(ParseError, JSMSG_IMPORT_DECL_AT_TOP_LEVEL);
|
error(JSMSG_IMPORT_DECL_AT_TOP_LEVEL);
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4861,7 +4886,7 @@ Parser<FullParseHandler>::importDeclaration()
|
||||||
return null();
|
return null();
|
||||||
|
|
||||||
if (tt != TOK_LC && tt != TOK_MUL) {
|
if (tt != TOK_LC && tt != TOK_MUL) {
|
||||||
qeport(ParseError, JSMSG_NAMED_IMPORTS_OR_NAMESPACE_IMPORT);
|
error(JSMSG_NAMED_IMPORTS_OR_NAMESPACE_IMPORT);
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4877,7 +4902,7 @@ Parser<FullParseHandler>::importDeclaration()
|
||||||
return null();
|
return null();
|
||||||
|
|
||||||
if (tt != TOK_NAME || tokenStream.currentName() != context->names().from) {
|
if (tt != TOK_NAME || tokenStream.currentName() != context->names().from) {
|
||||||
qeport(ParseError, JSMSG_FROM_AFTER_IMPORT_CLAUSE);
|
error(JSMSG_FROM_AFTER_IMPORT_CLAUSE);
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4890,7 +4915,7 @@ Parser<FullParseHandler>::importDeclaration()
|
||||||
// equivalent to |import {} from 'a'|.
|
// equivalent to |import {} from 'a'|.
|
||||||
importSpecSet->pn_pos.end = importSpecSet->pn_pos.begin;
|
importSpecSet->pn_pos.end = importSpecSet->pn_pos.begin;
|
||||||
} else {
|
} else {
|
||||||
qeport(ParseError, JSMSG_DECLARATION_AFTER_IMPORT);
|
error(JSMSG_DECLARATION_AFTER_IMPORT);
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4928,7 +4953,7 @@ Parser<FullParseHandler>::checkExportedName(JSAtom* exportName)
|
||||||
if (!AtomToPrintableString(context, exportName, &str))
|
if (!AtomToPrintableString(context, exportName, &str))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
qeport(ParseError, JSMSG_DUPLICATE_EXPORT_NAME, str.ptr());
|
error(JSMSG_DUPLICATE_EXPORT_NAME, str.ptr());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4971,7 +4996,7 @@ Parser<FullParseHandler>::exportDeclaration()
|
||||||
MOZ_ASSERT(tokenStream.currentToken().type == TOK_EXPORT);
|
MOZ_ASSERT(tokenStream.currentToken().type == TOK_EXPORT);
|
||||||
|
|
||||||
if (!pc->atModuleLevel()) {
|
if (!pc->atModuleLevel()) {
|
||||||
qeport(ParseError, JSMSG_EXPORT_DECL_AT_TOP_LEVEL);
|
error(JSMSG_EXPORT_DECL_AT_TOP_LEVEL);
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -5090,7 +5115,7 @@ Parser<FullParseHandler>::exportDeclaration()
|
||||||
if (!tokenStream.getToken(&tt))
|
if (!tokenStream.getToken(&tt))
|
||||||
return null();
|
return null();
|
||||||
if (tt != TOK_NAME || tokenStream.currentName() != context->names().from) {
|
if (tt != TOK_NAME || tokenStream.currentName() != context->names().from) {
|
||||||
qeport(ParseError, JSMSG_FROM_AFTER_EXPORT_STAR);
|
error(JSMSG_FROM_AFTER_EXPORT_STAR);
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -5226,7 +5251,7 @@ Parser<FullParseHandler>::exportDeclaration()
|
||||||
MOZ_FALLTHROUGH;
|
MOZ_FALLTHROUGH;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
qeport(ParseError, JSMSG_DECLARATION_AFTER_EXPORT);
|
error(JSMSG_DECLARATION_AFTER_EXPORT);
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -5302,7 +5327,7 @@ Parser<ParseHandler>::ifStatement(YieldHandling yieldHandling)
|
||||||
if (!tokenStream.peekToken(&tt, TokenStream::Operand))
|
if (!tokenStream.peekToken(&tt, TokenStream::Operand))
|
||||||
return null();
|
return null();
|
||||||
if (tt == TOK_SEMI) {
|
if (tt == TOK_SEMI) {
|
||||||
if (!qeport(ParseExtraWarning, JSMSG_EMPTY_CONSEQUENT))
|
if (!extraWarning(JSMSG_EMPTY_CONSEQUENT))
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -5776,7 +5801,7 @@ Parser<ParseHandler>::switchStatement(YieldHandling yieldHandling)
|
||||||
switch (tt) {
|
switch (tt) {
|
||||||
case TOK_DEFAULT:
|
case TOK_DEFAULT:
|
||||||
if (seenDefault) {
|
if (seenDefault) {
|
||||||
qeport(ParseError, JSMSG_TOO_MANY_DEFAULTS);
|
error(JSMSG_TOO_MANY_DEFAULTS);
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
seenDefault = true;
|
seenDefault = true;
|
||||||
|
|
@ -5790,7 +5815,7 @@ Parser<ParseHandler>::switchStatement(YieldHandling yieldHandling)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
qeport(ParseError, JSMSG_BAD_SWITCH);
|
error(JSMSG_BAD_SWITCH);
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -5873,7 +5898,7 @@ Parser<ParseHandler>::continueStatement(YieldHandling yieldHandling)
|
||||||
stmt = ParseContext::Statement::findNearest(stmt, isLoop);
|
stmt = ParseContext::Statement::findNearest(stmt, isLoop);
|
||||||
if (!stmt) {
|
if (!stmt) {
|
||||||
if (foundLoop)
|
if (foundLoop)
|
||||||
qeport(ParseError, JSMSG_LABEL_NOT_FOUND);
|
error(JSMSG_LABEL_NOT_FOUND);
|
||||||
else
|
else
|
||||||
reportWithOffset(ParseError, false, begin, JSMSG_BAD_CONTINUE);
|
reportWithOffset(ParseError, false, begin, JSMSG_BAD_CONTINUE);
|
||||||
return null();
|
return null();
|
||||||
|
|
@ -5895,7 +5920,7 @@ Parser<ParseHandler>::continueStatement(YieldHandling yieldHandling)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (!pc->findInnermostStatement(isLoop)) {
|
} else if (!pc->findInnermostStatement(isLoop)) {
|
||||||
qeport(ParseError, JSMSG_BAD_CONTINUE);
|
error(JSMSG_BAD_CONTINUE);
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -5925,7 +5950,7 @@ Parser<ParseHandler>::breakStatement(YieldHandling yieldHandling)
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!pc->findInnermostStatement<ParseContext::LabelStatement>(hasSameLabel)) {
|
if (!pc->findInnermostStatement<ParseContext::LabelStatement>(hasSameLabel)) {
|
||||||
qeport(ParseError, JSMSG_LABEL_NOT_FOUND);
|
error(JSMSG_LABEL_NOT_FOUND);
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -6084,7 +6109,7 @@ Parser<ParseHandler>::yieldExpression(InHandling inHandling)
|
||||||
return null();
|
return null();
|
||||||
|
|
||||||
if (!pc->isFunctionBox()) {
|
if (!pc->isFunctionBox()) {
|
||||||
qeport(ParseError, JSMSG_BAD_RETURN_OR_YIELD, js_yield_str);
|
error(JSMSG_BAD_RETURN_OR_YIELD, js_yield_str);
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -6210,7 +6235,7 @@ Parser<ParseHandler>::labeledItem(YieldHandling yieldHandling)
|
||||||
// GeneratorDeclaration is only matched by HoistableDeclaration in
|
// GeneratorDeclaration is only matched by HoistableDeclaration in
|
||||||
// StatementListItem, so generators can't be inside labels.
|
// StatementListItem, so generators can't be inside labels.
|
||||||
if (next == TOK_MUL) {
|
if (next == TOK_MUL) {
|
||||||
qeport(ParseError, JSMSG_GENERATOR_LABEL);
|
error(JSMSG_GENERATOR_LABEL);
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -6218,7 +6243,7 @@ Parser<ParseHandler>::labeledItem(YieldHandling yieldHandling)
|
||||||
// is ever matched. Per Annex B.3.2 that modifies this text, this
|
// is ever matched. Per Annex B.3.2 that modifies this text, this
|
||||||
// applies only to strict mode code.
|
// applies only to strict mode code.
|
||||||
if (pc->sc()->strict()) {
|
if (pc->sc()->strict()) {
|
||||||
qeport(ParseError, JSMSG_FUNCTION_LABEL);
|
error(JSMSG_FUNCTION_LABEL);
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -6271,11 +6296,11 @@ Parser<ParseHandler>::throwStatement(YieldHandling yieldHandling)
|
||||||
if (!tokenStream.peekTokenSameLine(&tt, TokenStream::Operand))
|
if (!tokenStream.peekTokenSameLine(&tt, TokenStream::Operand))
|
||||||
return null();
|
return null();
|
||||||
if (tt == TOK_EOF || tt == TOK_SEMI || tt == TOK_RC) {
|
if (tt == TOK_EOF || tt == TOK_SEMI || tt == TOK_RC) {
|
||||||
qeport(ParseError, JSMSG_MISSING_EXPR_AFTER_THROW);
|
error(JSMSG_MISSING_EXPR_AFTER_THROW);
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
if (tt == TOK_EOL) {
|
if (tt == TOK_EOL) {
|
||||||
qeport(ParseError, JSMSG_LINE_BREAK_AFTER_THROW);
|
error(JSMSG_LINE_BREAK_AFTER_THROW);
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -6349,7 +6374,7 @@ Parser<ParseHandler>::tryStatement(YieldHandling yieldHandling)
|
||||||
|
|
||||||
/* Check for another catch after unconditional catch. */
|
/* Check for another catch after unconditional catch. */
|
||||||
if (hasUnconditionalCatch) {
|
if (hasUnconditionalCatch) {
|
||||||
qeport(ParseError, JSMSG_CATCH_AFTER_GENERAL);
|
error(JSMSG_CATCH_AFTER_GENERAL);
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -6397,7 +6422,7 @@ Parser<ParseHandler>::tryStatement(YieldHandling yieldHandling)
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
qeport(ParseError, JSMSG_CATCH_IDENTIFIER);
|
error(JSMSG_CATCH_IDENTIFIER);
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -6465,7 +6490,7 @@ Parser<ParseHandler>::tryStatement(YieldHandling yieldHandling)
|
||||||
tokenStream.ungetToken();
|
tokenStream.ungetToken();
|
||||||
}
|
}
|
||||||
if (!catchList && !finallyBlock) {
|
if (!catchList && !finallyBlock) {
|
||||||
qeport(ParseError, JSMSG_CATCH_OR_FINALLY);
|
error(JSMSG_CATCH_OR_FINALLY);
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -6610,7 +6635,7 @@ Parser<ParseHandler>::classDefinition(YieldHandling yieldHandling,
|
||||||
tokenStream.ungetToken();
|
tokenStream.ungetToken();
|
||||||
} else {
|
} else {
|
||||||
// Class statements must have a bound name
|
// Class statements must have a bound name
|
||||||
qeport(ParseError, JSMSG_UNNAMED_CLASS_STMT);
|
error(JSMSG_UNNAMED_CLASS_STMT);
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -6671,7 +6696,7 @@ Parser<ParseHandler>::classDefinition(YieldHandling yieldHandling,
|
||||||
return null();
|
return null();
|
||||||
if (tt == TOK_RC) {
|
if (tt == TOK_RC) {
|
||||||
tokenStream.consumeKnownToken(tt, TokenStream::KeywordIsName);
|
tokenStream.consumeKnownToken(tt, TokenStream::KeywordIsName);
|
||||||
qeport(ParseError, JSMSG_UNEXPECTED_TOKEN, "property name", TokenKindToDesc(tt));
|
error(JSMSG_UNEXPECTED_TOKEN, "property name", TokenKindToDesc(tt));
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -6702,7 +6727,7 @@ Parser<ParseHandler>::classDefinition(YieldHandling yieldHandling,
|
||||||
propType != PropertyType::AsyncMethod &&
|
propType != PropertyType::AsyncMethod &&
|
||||||
propType != PropertyType::Constructor && propType != PropertyType::DerivedConstructor)
|
propType != PropertyType::Constructor && propType != PropertyType::DerivedConstructor)
|
||||||
{
|
{
|
||||||
qeport(ParseError, JSMSG_BAD_METHOD_DEF);
|
error(JSMSG_BAD_METHOD_DEF);
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -6949,7 +6974,7 @@ Parser<ParseHandler>::statement(YieldHandling yieldHandling)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (forbiddenLetDeclaration) {
|
if (forbiddenLetDeclaration) {
|
||||||
qeport(ParseError, JSMSG_FORBIDDEN_AS_STATEMENT, "lexical declarations");
|
error(JSMSG_FORBIDDEN_AS_STATEMENT, "lexical declarations");
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -7003,7 +7028,7 @@ Parser<ParseHandler>::statement(YieldHandling yieldHandling)
|
||||||
// detected this way, so don't bother passing around an extra parameter
|
// detected this way, so don't bother passing around an extra parameter
|
||||||
// everywhere.
|
// everywhere.
|
||||||
if (!pc->isFunctionBox()) {
|
if (!pc->isFunctionBox()) {
|
||||||
qeport(ParseError, JSMSG_BAD_RETURN_OR_YIELD, js_return_str);
|
error(JSMSG_BAD_RETURN_OR_YIELD, js_return_str);
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
return returnStatement(yieldHandling);
|
return returnStatement(yieldHandling);
|
||||||
|
|
@ -7031,12 +7056,12 @@ Parser<ParseHandler>::statement(YieldHandling yieldHandling)
|
||||||
// statement of |if| or |else|, but Parser::consequentOrAlternative
|
// statement of |if| or |else|, but Parser::consequentOrAlternative
|
||||||
// handles that).
|
// handles that).
|
||||||
case TOK_FUNCTION:
|
case TOK_FUNCTION:
|
||||||
qeport(ParseError, JSMSG_FORBIDDEN_AS_STATEMENT, "function declarations");
|
error(JSMSG_FORBIDDEN_AS_STATEMENT, "function declarations");
|
||||||
return null();
|
return null();
|
||||||
|
|
||||||
// |class| is also forbidden by lookahead restriction.
|
// |class| is also forbidden by lookahead restriction.
|
||||||
case TOK_CLASS:
|
case TOK_CLASS:
|
||||||
qeport(ParseError, JSMSG_FORBIDDEN_AS_STATEMENT, "classes");
|
error(JSMSG_FORBIDDEN_AS_STATEMENT, "classes");
|
||||||
return null();
|
return null();
|
||||||
|
|
||||||
// ImportDeclaration (only inside modules)
|
// ImportDeclaration (only inside modules)
|
||||||
|
|
@ -7050,11 +7075,11 @@ Parser<ParseHandler>::statement(YieldHandling yieldHandling)
|
||||||
// Miscellaneous error cases arguably better caught here than elsewhere.
|
// Miscellaneous error cases arguably better caught here than elsewhere.
|
||||||
|
|
||||||
case TOK_CATCH:
|
case TOK_CATCH:
|
||||||
qeport(ParseError, JSMSG_CATCH_WITHOUT_TRY);
|
error(JSMSG_CATCH_WITHOUT_TRY);
|
||||||
return null();
|
return null();
|
||||||
|
|
||||||
case TOK_FINALLY:
|
case TOK_FINALLY:
|
||||||
qeport(ParseError, JSMSG_FINALLY_WITHOUT_TRY);
|
error(JSMSG_FINALLY_WITHOUT_TRY);
|
||||||
return null();
|
return null();
|
||||||
|
|
||||||
// NOTE: default case handled in the ExpressionStatement section.
|
// NOTE: default case handled in the ExpressionStatement section.
|
||||||
|
|
@ -7095,7 +7120,7 @@ Parser<ParseHandler>::statementListItem(YieldHandling yieldHandling,
|
||||||
if (!canHaveDirectives && tokenStream.currentToken().atom() == context->names().useAsm) {
|
if (!canHaveDirectives && tokenStream.currentToken().atom() == context->names().useAsm) {
|
||||||
if (!abortIfSyntaxParser())
|
if (!abortIfSyntaxParser())
|
||||||
return null();
|
return null();
|
||||||
if (!qeport(ParseWarning, JSMSG_USE_ASM_DIRECTIVE_FAIL))
|
if (!warning(JSMSG_USE_ASM_DIRECTIVE_FAIL))
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
return expressionStatement(yieldHandling);
|
return expressionStatement(yieldHandling);
|
||||||
|
|
@ -7189,7 +7214,7 @@ Parser<ParseHandler>::statementListItem(YieldHandling yieldHandling,
|
||||||
// detected this way, so don't bother passing around an extra parameter
|
// detected this way, so don't bother passing around an extra parameter
|
||||||
// everywhere.
|
// everywhere.
|
||||||
if (!pc->isFunctionBox()) {
|
if (!pc->isFunctionBox()) {
|
||||||
qeport(ParseError, JSMSG_BAD_RETURN_OR_YIELD, js_return_str);
|
error(JSMSG_BAD_RETURN_OR_YIELD, js_return_str);
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
return returnStatement(yieldHandling);
|
return returnStatement(yieldHandling);
|
||||||
|
|
@ -7241,11 +7266,11 @@ Parser<ParseHandler>::statementListItem(YieldHandling yieldHandling,
|
||||||
// Miscellaneous error cases arguably better caught here than elsewhere.
|
// Miscellaneous error cases arguably better caught here than elsewhere.
|
||||||
|
|
||||||
case TOK_CATCH:
|
case TOK_CATCH:
|
||||||
qeport(ParseError, JSMSG_CATCH_WITHOUT_TRY);
|
error(JSMSG_CATCH_WITHOUT_TRY);
|
||||||
return null();
|
return null();
|
||||||
|
|
||||||
case TOK_FINALLY:
|
case TOK_FINALLY:
|
||||||
qeport(ParseError, JSMSG_FINALLY_WITHOUT_TRY);
|
error(JSMSG_FINALLY_WITHOUT_TRY);
|
||||||
return null();
|
return null();
|
||||||
|
|
||||||
// NOTE: default case handled in the ExpressionStatement section.
|
// NOTE: default case handled in the ExpressionStatement section.
|
||||||
|
|
@ -7290,8 +7315,7 @@ Parser<ParseHandler>::expr(InHandling inHandling, YieldHandling yieldHandling,
|
||||||
if (!tokenStream.peekToken(&tt))
|
if (!tokenStream.peekToken(&tt))
|
||||||
return null();
|
return null();
|
||||||
if (tt != TOK_ARROW) {
|
if (tt != TOK_ARROW) {
|
||||||
qeport(ParseError, JSMSG_UNEXPECTED_TOKEN,
|
error(JSMSG_UNEXPECTED_TOKEN, "expression", TokenKindToDesc(TOK_RP));
|
||||||
"expression", TokenKindToDesc(TOK_RP));
|
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -7448,7 +7472,7 @@ Parser<ParseHandler>::orExpr1(InHandling inHandling, YieldHandling yieldHandling
|
||||||
return null();
|
return null();
|
||||||
// Report an error for unary expressions on the LHS of **.
|
// Report an error for unary expressions on the LHS of **.
|
||||||
if (tok == TOK_POW && handler.isUnparenthesizedUnaryExpression(pn)) {
|
if (tok == TOK_POW && handler.isUnparenthesizedUnaryExpression(pn)) {
|
||||||
qeport(ParseError, JSMSG_BAD_POW_LEFTSIDE);
|
error(JSMSG_BAD_POW_LEFTSIDE);
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
pnk = BinaryOpTokenKindToParseNodeKind(tok);
|
pnk = BinaryOpTokenKindToParseNodeKind(tok);
|
||||||
|
|
@ -7529,7 +7553,7 @@ Parser<ParseHandler>::checkAndMarkAsAssignmentLhs(Node target, AssignmentFlavor
|
||||||
|
|
||||||
if (handler.isUnparenthesizedDestructuringPattern(target)) {
|
if (handler.isUnparenthesizedDestructuringPattern(target)) {
|
||||||
if (flavor == CompoundAssignment) {
|
if (flavor == CompoundAssignment) {
|
||||||
qeport(ParseError, JSMSG_BAD_DESTRUCT_ASS);
|
error(JSMSG_BAD_DESTRUCT_ASS);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -7668,8 +7692,7 @@ Parser<ParseHandler>::assignExpr(InHandling inHandling, YieldHandling yieldHandl
|
||||||
if (!tokenStream.getToken(&tt))
|
if (!tokenStream.getToken(&tt))
|
||||||
return null();
|
return null();
|
||||||
if (tt != TOK_ARROW) {
|
if (tt != TOK_ARROW) {
|
||||||
qeport(ParseError, JSMSG_UNEXPECTED_TOKEN,
|
error(JSMSG_UNEXPECTED_TOKEN, "'=>' after argument list", TokenKindToDesc(tt));
|
||||||
"'=>' after argument list", TokenKindToDesc(tt));
|
|
||||||
|
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
|
|
@ -7707,7 +7730,7 @@ Parser<ParseHandler>::assignExpr(InHandling inHandling, YieldHandling yieldHandl
|
||||||
MOZ_ASSERT(next == TOK_ARROW || next == TOK_EOL);
|
MOZ_ASSERT(next == TOK_ARROW || next == TOK_EOL);
|
||||||
|
|
||||||
if (next != TOK_ARROW) {
|
if (next != TOK_ARROW) {
|
||||||
qeport(ParseError, JSMSG_LINE_BREAK_BEFORE_ARROW);
|
error(JSMSG_LINE_BREAK_BEFORE_ARROW);
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
tokenStream.consumeKnownToken(TOK_ARROW);
|
tokenStream.consumeKnownToken(TOK_ARROW);
|
||||||
|
|
@ -8027,7 +8050,7 @@ Parser<ParseHandler>::unaryExpr(YieldHandling yieldHandling, TripledotHandling t
|
||||||
if (!pc->isAsync()) {
|
if (!pc->isAsync()) {
|
||||||
// TOK_AWAIT can be returned in module, even if it's not inside
|
// TOK_AWAIT can be returned in module, even if it's not inside
|
||||||
// async function.
|
// async function.
|
||||||
qeport(ParseError, JSMSG_RESERVED_ID, "await");
|
error(JSMSG_RESERVED_ID, "await");
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -8180,7 +8203,7 @@ Parser<ParseHandler>::comprehensionFor(GeneratorKind comprehensionKind)
|
||||||
MUST_MATCH_TOKEN(TOK_NAME, JSMSG_NO_VARIABLE_NAME);
|
MUST_MATCH_TOKEN(TOK_NAME, JSMSG_NO_VARIABLE_NAME);
|
||||||
RootedPropertyName name(context, tokenStream.currentName());
|
RootedPropertyName name(context, tokenStream.currentName());
|
||||||
if (name == context->names().let) {
|
if (name == context->names().let) {
|
||||||
qeport(ParseError, JSMSG_LET_COMP_BINDING);
|
error(JSMSG_LET_COMP_BINDING);
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
TokenPos namePos = pos();
|
TokenPos namePos = pos();
|
||||||
|
|
@ -8191,7 +8214,7 @@ Parser<ParseHandler>::comprehensionFor(GeneratorKind comprehensionKind)
|
||||||
if (!tokenStream.matchContextualKeyword(&matched, context->names().of))
|
if (!tokenStream.matchContextualKeyword(&matched, context->names().of))
|
||||||
return null();
|
return null();
|
||||||
if (!matched) {
|
if (!matched) {
|
||||||
qeport(ParseError, JSMSG_OF_AFTER_FOR_NAME);
|
error(JSMSG_OF_AFTER_FOR_NAME);
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -8252,7 +8275,7 @@ Parser<ParseHandler>::comprehensionIf(GeneratorKind comprehensionKind)
|
||||||
|
|
||||||
/* Check for (a = b) and warn about possible (a == b) mistype. */
|
/* Check for (a = b) and warn about possible (a == b) mistype. */
|
||||||
if (handler.isUnparenthesizedAssignment(cond)) {
|
if (handler.isUnparenthesizedAssignment(cond)) {
|
||||||
if (!qeport(ParseExtraWarning, JSMSG_EQUAL_AS_ASSIGN))
|
if (!extraWarning(JSMSG_EQUAL_AS_ASSIGN))
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -8529,14 +8552,14 @@ Parser<ParseHandler>::memberExpr(YieldHandling yieldHandling, TripledotHandling
|
||||||
if (tt == TOK_NAME) {
|
if (tt == TOK_NAME) {
|
||||||
PropertyName* field = tokenStream.currentName();
|
PropertyName* field = tokenStream.currentName();
|
||||||
if (handler.isSuperBase(lhs) && !checkAndMarkSuperScope()) {
|
if (handler.isSuperBase(lhs) && !checkAndMarkSuperScope()) {
|
||||||
qeport(ParseError, JSMSG_BAD_SUPERPROP, "property");
|
error(JSMSG_BAD_SUPERPROP, "property");
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
nextMember = handler.newPropertyAccess(lhs, field, pos().end);
|
nextMember = handler.newPropertyAccess(lhs, field, pos().end);
|
||||||
if (!nextMember)
|
if (!nextMember)
|
||||||
return null();
|
return null();
|
||||||
} else {
|
} else {
|
||||||
qeport(ParseError, JSMSG_NAME_AFTER_DOT);
|
error(JSMSG_NAME_AFTER_DOT);
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
} else if (tt == TOK_LB) {
|
} else if (tt == TOK_LB) {
|
||||||
|
|
@ -8547,7 +8570,7 @@ Parser<ParseHandler>::memberExpr(YieldHandling yieldHandling, TripledotHandling
|
||||||
MUST_MATCH_TOKEN(TOK_RB, JSMSG_BRACKET_IN_INDEX);
|
MUST_MATCH_TOKEN(TOK_RB, JSMSG_BRACKET_IN_INDEX);
|
||||||
|
|
||||||
if (handler.isSuperBase(lhs) && !checkAndMarkSuperScope()) {
|
if (handler.isSuperBase(lhs) && !checkAndMarkSuperScope()) {
|
||||||
qeport(ParseError, JSMSG_BAD_SUPERPROP, "member");
|
error(JSMSG_BAD_SUPERPROP, "member");
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
nextMember = handler.newPropertyByValue(lhs, propExpr, pos().end);
|
nextMember = handler.newPropertyByValue(lhs, propExpr, pos().end);
|
||||||
|
|
@ -8559,12 +8582,12 @@ Parser<ParseHandler>::memberExpr(YieldHandling yieldHandling, TripledotHandling
|
||||||
{
|
{
|
||||||
if (handler.isSuperBase(lhs)) {
|
if (handler.isSuperBase(lhs)) {
|
||||||
if (!pc->sc()->allowSuperCall()) {
|
if (!pc->sc()->allowSuperCall()) {
|
||||||
qeport(ParseError, JSMSG_BAD_SUPERCALL);
|
error(JSMSG_BAD_SUPERCALL);
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tt != TOK_LP) {
|
if (tt != TOK_LP) {
|
||||||
qeport(ParseError, JSMSG_BAD_SUPER);
|
error(JSMSG_BAD_SUPER);
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -8591,7 +8614,7 @@ Parser<ParseHandler>::memberExpr(YieldHandling yieldHandling, TripledotHandling
|
||||||
return null();
|
return null();
|
||||||
} else {
|
} else {
|
||||||
if (options().selfHostingMode && handler.isPropertyAccess(lhs)) {
|
if (options().selfHostingMode && handler.isPropertyAccess(lhs)) {
|
||||||
qeport(ParseError, JSMSG_SELFHOSTED_METHOD_CALL);
|
error(JSMSG_SELFHOSTED_METHOD_CALL);
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -8673,7 +8696,7 @@ Parser<ParseHandler>::memberExpr(YieldHandling yieldHandling, TripledotHandling
|
||||||
}
|
}
|
||||||
|
|
||||||
if (handler.isSuperBase(lhs)) {
|
if (handler.isSuperBase(lhs)) {
|
||||||
qeport(ParseError, JSMSG_BAD_SUPER);
|
error(JSMSG_BAD_SUPER);
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -8726,7 +8749,7 @@ Parser<ParseHandler>::labelOrIdentifierReference(YieldHandling yieldHandling,
|
||||||
? "static"
|
? "static"
|
||||||
: nullptr;
|
: nullptr;
|
||||||
if (badName) {
|
if (badName) {
|
||||||
qeport(ParseError, JSMSG_RESERVED_ID, badName);
|
error(JSMSG_RESERVED_ID, badName);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -8735,7 +8758,7 @@ Parser<ParseHandler>::labelOrIdentifierReference(YieldHandling yieldHandling,
|
||||||
pc->sc()->strict() ||
|
pc->sc()->strict() ||
|
||||||
versionNumber() >= JSVERSION_1_7)
|
versionNumber() >= JSVERSION_1_7)
|
||||||
{
|
{
|
||||||
qeport(ParseError, JSMSG_RESERVED_ID, "yield");
|
error(JSMSG_RESERVED_ID, "yield");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -8771,7 +8794,7 @@ Parser<ParseHandler>::bindingIdentifier(YieldHandling yieldHandling)
|
||||||
? "eval"
|
? "eval"
|
||||||
: nullptr;
|
: nullptr;
|
||||||
if (badName) {
|
if (badName) {
|
||||||
qeport(ParseError, JSMSG_BAD_STRICT_ASSIGN, badName);
|
error(JSMSG_BAD_STRICT_ASSIGN, badName);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -8781,7 +8804,7 @@ Parser<ParseHandler>::bindingIdentifier(YieldHandling yieldHandling)
|
||||||
? "static"
|
? "static"
|
||||||
: nullptr;
|
: nullptr;
|
||||||
if (badName) {
|
if (badName) {
|
||||||
qeport(ParseError, JSMSG_RESERVED_ID, badName);
|
error(JSMSG_RESERVED_ID, badName);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -8790,7 +8813,7 @@ Parser<ParseHandler>::bindingIdentifier(YieldHandling yieldHandling)
|
||||||
pc->sc()->strict() ||
|
pc->sc()->strict() ||
|
||||||
versionNumber() >= JSVERSION_1_7)
|
versionNumber() >= JSVERSION_1_7)
|
||||||
{
|
{
|
||||||
qeport(ParseError, JSMSG_RESERVED_ID, "yield");
|
error(JSMSG_RESERVED_ID, "yield");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -8889,7 +8912,7 @@ Parser<ParseHandler>::arrayInitializer(YieldHandling yieldHandling, PossibleErro
|
||||||
TokenStream::Modifier modifier = TokenStream::Operand;
|
TokenStream::Modifier modifier = TokenStream::Operand;
|
||||||
for (; ; index++) {
|
for (; ; index++) {
|
||||||
if (index >= NativeObject::MAX_DENSE_ELEMENTS_COUNT) {
|
if (index >= NativeObject::MAX_DENSE_ELEMENTS_COUNT) {
|
||||||
qeport(ParseError, JSMSG_ARRAY_INIT_TOO_BIG);
|
error(JSMSG_ARRAY_INIT_TOO_BIG);
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -8999,7 +9022,7 @@ Parser<ParseHandler>::propertyName(YieldHandling yieldHandling, Node propList,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isAsync && isGenerator) {
|
if (isAsync && isGenerator) {
|
||||||
qeport(ParseError, JSMSG_ASYNC_GENERATOR);
|
error(JSMSG_ASYNC_GENERATOR);
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -9112,7 +9135,7 @@ Parser<ParseHandler>::propertyName(YieldHandling yieldHandling, Node propList,
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
qeport(ParseError, JSMSG_BAD_PROP_ID);
|
error(JSMSG_BAD_PROP_ID);
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -9122,7 +9145,7 @@ Parser<ParseHandler>::propertyName(YieldHandling yieldHandling, Node propList,
|
||||||
|
|
||||||
if (tt == TOK_COLON) {
|
if (tt == TOK_COLON) {
|
||||||
if (isGenerator) {
|
if (isGenerator) {
|
||||||
qeport(ParseError, JSMSG_BAD_PROP_ID);
|
error(JSMSG_BAD_PROP_ID);
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
*propType = PropertyType::Normal;
|
*propType = PropertyType::Normal;
|
||||||
|
|
@ -9131,7 +9154,7 @@ Parser<ParseHandler>::propertyName(YieldHandling yieldHandling, Node propList,
|
||||||
|
|
||||||
if (ltok == TOK_NAME && (tt == TOK_COMMA || tt == TOK_RC || tt == TOK_ASSIGN)) {
|
if (ltok == TOK_NAME && (tt == TOK_COMMA || tt == TOK_RC || tt == TOK_ASSIGN)) {
|
||||||
if (isGenerator) {
|
if (isGenerator) {
|
||||||
qeport(ParseError, JSMSG_BAD_PROP_ID);
|
error(JSMSG_BAD_PROP_ID);
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
tokenStream.ungetToken();
|
tokenStream.ungetToken();
|
||||||
|
|
@ -9152,7 +9175,7 @@ Parser<ParseHandler>::propertyName(YieldHandling yieldHandling, Node propList,
|
||||||
return propName;
|
return propName;
|
||||||
}
|
}
|
||||||
|
|
||||||
qeport(ParseError, JSMSG_COLON_AFTER_ID);
|
error(JSMSG_COLON_AFTER_ID);
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -9263,7 +9286,7 @@ Parser<ParseHandler>::objectLiteral(YieldHandling yieldHandling, PossibleError*
|
||||||
return null();
|
return null();
|
||||||
|
|
||||||
if (propToken != TOK_NAME && propToken != TOK_YIELD) {
|
if (propToken != TOK_NAME && propToken != TOK_YIELD) {
|
||||||
qeport(ParseError, JSMSG_RESERVED_ID, TokenKindToDesc(propToken));
|
error(JSMSG_RESERVED_ID, TokenKindToDesc(propToken));
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -9288,7 +9311,7 @@ Parser<ParseHandler>::objectLiteral(YieldHandling yieldHandling, PossibleError*
|
||||||
return null();
|
return null();
|
||||||
|
|
||||||
if (propToken != TOK_NAME && propToken != TOK_YIELD) {
|
if (propToken != TOK_NAME && propToken != TOK_YIELD) {
|
||||||
qeport(ParseError, JSMSG_RESERVED_ID, TokenKindToDesc(propToken));
|
error(JSMSG_RESERVED_ID, TokenKindToDesc(propToken));
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -9312,7 +9335,7 @@ Parser<ParseHandler>::objectLiteral(YieldHandling yieldHandling, PossibleError*
|
||||||
// Destructuring defaults are definitely not allowed in this object literal,
|
// Destructuring defaults are definitely not allowed in this object literal,
|
||||||
// because of something the caller knows about the preceding code.
|
// because of something the caller knows about the preceding code.
|
||||||
// For example, maybe the preceding token is an operator: `x + {y=z}`.
|
// For example, maybe the preceding token is an operator: `x + {y=z}`.
|
||||||
qeport(ParseError, JSMSG_COLON_AFTER_ID);
|
error(JSMSG_COLON_AFTER_ID);
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -9371,7 +9394,7 @@ Parser<ParseHandler>::objectLiteral(YieldHandling yieldHandling, PossibleError*
|
||||||
if (tt == TOK_RC)
|
if (tt == TOK_RC)
|
||||||
break;
|
break;
|
||||||
if (tt != TOK_COMMA) {
|
if (tt != TOK_COMMA) {
|
||||||
qeport(ParseError, JSMSG_CURLY_AFTER_LIST);
|
error(JSMSG_CURLY_AFTER_LIST);
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -9420,7 +9443,7 @@ Parser<ParseHandler>::tryNewTarget(Node &newTarget)
|
||||||
if (!tokenStream.getToken(&next))
|
if (!tokenStream.getToken(&next))
|
||||||
return false;
|
return false;
|
||||||
if (next != TOK_NAME || tokenStream.currentName() != context->names().target) {
|
if (next != TOK_NAME || tokenStream.currentName() != context->names().target) {
|
||||||
qeport(ParseError, JSMSG_UNEXPECTED_TOKEN, "target", TokenKindToDesc(next));
|
error(JSMSG_UNEXPECTED_TOKEN, "target", TokenKindToDesc(next));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -9475,8 +9498,7 @@ Parser<ParseHandler>::primaryExpr(YieldHandling yieldHandling, TripledotHandling
|
||||||
if (!tokenStream.peekToken(&next))
|
if (!tokenStream.peekToken(&next))
|
||||||
return null();
|
return null();
|
||||||
if (next != TOK_ARROW) {
|
if (next != TOK_ARROW) {
|
||||||
qeport(ParseError, JSMSG_UNEXPECTED_TOKEN,
|
error(JSMSG_UNEXPECTED_TOKEN, "expression", TokenKindToDesc(TOK_RP));
|
||||||
"expression", TokenKindToDesc(TOK_RP));
|
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -9563,7 +9585,7 @@ Parser<ParseHandler>::primaryExpr(YieldHandling yieldHandling, TripledotHandling
|
||||||
// name, closing parenthesis, and arrow, and allow it only if all are
|
// name, closing parenthesis, and arrow, and allow it only if all are
|
||||||
// present.
|
// present.
|
||||||
if (tripledotHandling != TripledotAllowed) {
|
if (tripledotHandling != TripledotAllowed) {
|
||||||
qeport(ParseError, JSMSG_UNEXPECTED_TOKEN, "expression", TokenKindToDesc(tt));
|
error(JSMSG_UNEXPECTED_TOKEN, "expression", TokenKindToDesc(tt));
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -9585,8 +9607,7 @@ Parser<ParseHandler>::primaryExpr(YieldHandling yieldHandling, TripledotHandling
|
||||||
// or "arguments" should be prohibited. Argument-parsing code
|
// or "arguments" should be prohibited. Argument-parsing code
|
||||||
// handles that.
|
// handles that.
|
||||||
if (next != TOK_NAME && next != TOK_YIELD) {
|
if (next != TOK_NAME && next != TOK_YIELD) {
|
||||||
qeport(ParseError, JSMSG_UNEXPECTED_TOKEN,
|
error(JSMSG_UNEXPECTED_TOKEN, "rest argument name", TokenKindToDesc(next));
|
||||||
"rest argument name", TokenKindToDesc(next));
|
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -9594,8 +9615,7 @@ Parser<ParseHandler>::primaryExpr(YieldHandling yieldHandling, TripledotHandling
|
||||||
if (!tokenStream.getToken(&next))
|
if (!tokenStream.getToken(&next))
|
||||||
return null();
|
return null();
|
||||||
if (next != TOK_RP) {
|
if (next != TOK_RP) {
|
||||||
qeport(ParseError, JSMSG_UNEXPECTED_TOKEN,
|
error(JSMSG_UNEXPECTED_TOKEN, "closing parenthesis", TokenKindToDesc(next));
|
||||||
"closing parenthesis", TokenKindToDesc(next));
|
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -9604,8 +9624,7 @@ Parser<ParseHandler>::primaryExpr(YieldHandling yieldHandling, TripledotHandling
|
||||||
if (next != TOK_ARROW) {
|
if (next != TOK_ARROW) {
|
||||||
// Advance the scanner for proper error location reporting.
|
// Advance the scanner for proper error location reporting.
|
||||||
tokenStream.consumeKnownToken(next);
|
tokenStream.consumeKnownToken(next);
|
||||||
qeport(ParseError, JSMSG_UNEXPECTED_TOKEN,
|
error(JSMSG_UNEXPECTED_TOKEN, "'=>' after argument list", TokenKindToDesc(next));
|
||||||
"'=>' after argument list", TokenKindToDesc(next));
|
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -9616,7 +9635,7 @@ Parser<ParseHandler>::primaryExpr(YieldHandling yieldHandling, TripledotHandling
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
qeport(ParseError, JSMSG_UNEXPECTED_TOKEN, "expression", TokenKindToDesc(tt));
|
error(JSMSG_UNEXPECTED_TOKEN, "expression", TokenKindToDesc(tt));
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -9641,7 +9660,7 @@ Parser<ParseHandler>::warnOnceAboutExprClosure()
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (!cx->compartment()->warnedAboutExprClosure) {
|
if (!cx->compartment()->warnedAboutExprClosure) {
|
||||||
if (!qeport(ParseWarning, JSMSG_DEPRECATED_EXPR_CLOSURE))
|
if (!warning(JSMSG_DEPRECATED_EXPR_CLOSURE))
|
||||||
return false;
|
return false;
|
||||||
cx->compartment()->warnedAboutExprClosure = true;
|
cx->compartment()->warnedAboutExprClosure = true;
|
||||||
}
|
}
|
||||||
|
|
@ -9659,7 +9678,7 @@ Parser<ParseHandler>::warnOnceAboutForEach()
|
||||||
|
|
||||||
if (!cx->compartment()->warnedAboutForEach) {
|
if (!cx->compartment()->warnedAboutForEach) {
|
||||||
// Disabled warning spew.
|
// Disabled warning spew.
|
||||||
// if (!qeport(ParseWarning, JSMSG_DEPRECATED_FOR_EACH))
|
// if (!warning(JSMSG_DEPRECATED_FOR_EACH))
|
||||||
// return false;
|
// return false;
|
||||||
cx->compartment()->warnedAboutForEach = true;
|
cx->compartment()->warnedAboutForEach = true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -907,12 +907,14 @@ class Parser final : private JS::AutoGCRooter, public StrictModeGetter
|
||||||
bool reportHelper(ParseReportKind kind, bool strict, uint32_t offset,
|
bool reportHelper(ParseReportKind kind, bool strict, uint32_t offset,
|
||||||
unsigned errorNumber, va_list args);
|
unsigned errorNumber, va_list args);
|
||||||
public:
|
public:
|
||||||
bool qeport(ParseReportKind kind, unsigned errorNumber, ...);
|
|
||||||
bool reportWithNode(ParseReportKind kind, bool strict, Node pn, unsigned errorNumber, ...);
|
bool reportWithNode(ParseReportKind kind, bool strict, Node pn, unsigned errorNumber, ...);
|
||||||
bool reportNoOffset(ParseReportKind kind, bool strict, unsigned errorNumber, ...);
|
bool reportNoOffset(ParseReportKind kind, bool strict, unsigned errorNumber, ...);
|
||||||
bool reportWithOffset(ParseReportKind kind, bool strict, uint32_t offset, unsigned errorNumber,
|
bool reportWithOffset(ParseReportKind kind, bool strict, uint32_t offset, unsigned errorNumber,
|
||||||
...);
|
...);
|
||||||
|
|
||||||
|
/* Report the given error at the current offset. */
|
||||||
|
void error(unsigned errorNumber, ...);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Handle a strict mode error at the current offset. Report an error if in
|
* Handle a strict mode error at the current offset. Report an error if in
|
||||||
* strict mode code, or warn if not, using the given error number and
|
* strict mode code, or warn if not, using the given error number and
|
||||||
|
|
@ -920,6 +922,15 @@ class Parser final : private JS::AutoGCRooter, public StrictModeGetter
|
||||||
*/
|
*/
|
||||||
MOZ_MUST_USE bool strictModeError(unsigned errorNumber, ...);
|
MOZ_MUST_USE bool strictModeError(unsigned errorNumber, ...);
|
||||||
|
|
||||||
|
/* Report the given warning at the current offset. */
|
||||||
|
MOZ_MUST_USE bool warning(unsigned errorNumber, ...);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If extra warnings are enabled, report the given warning at the current
|
||||||
|
* offset.
|
||||||
|
*/
|
||||||
|
MOZ_MUST_USE bool extraWarning(unsigned errorNumber, ...);
|
||||||
|
|
||||||
Parser(ExclusiveContext* cx, LifoAlloc& alloc, const ReadOnlyCompileOptions& options,
|
Parser(ExclusiveContext* cx, LifoAlloc& alloc, const ReadOnlyCompileOptions& options,
|
||||||
const char16_t* chars, size_t length, bool foldConstants, UsedNameTracker& usedNames,
|
const char16_t* chars, size_t length, bool foldConstants, UsedNameTracker& usedNames,
|
||||||
Parser<SyntaxParseHandler>* syntaxParser, LazyScript* lazyOuterFunction);
|
Parser<SyntaxParseHandler>* syntaxParser, LazyScript* lazyOuterFunction);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue