mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-04 14:58:37 +09:00
Remove Parser::reportBadReturn
Report simpler errors that don't use the offset of a node as location.
This commit is contained in:
parent
07c1fa20ea
commit
f1f8d377a9
6 changed files with 11 additions and 30 deletions
|
|
@ -909,21 +909,6 @@ Parser<ParseHandler>::parse()
|
|||
return pn;
|
||||
}
|
||||
|
||||
template <typename ParseHandler>
|
||||
bool
|
||||
Parser<ParseHandler>::reportBadReturn(Node pn, ParseReportKind kind,
|
||||
unsigned errnum, unsigned anonerrnum)
|
||||
{
|
||||
JSAutoByteString name;
|
||||
if (JSAtom* atom = pc->functionBox()->function()->explicitName()) {
|
||||
if (!AtomToPrintableString(context, atom, &name))
|
||||
return false;
|
||||
} else {
|
||||
errnum = anonerrnum;
|
||||
}
|
||||
return reportWithNode(kind, pc->sc()->strict(), pn, errnum, name.ptr());
|
||||
}
|
||||
|
||||
/*
|
||||
* Strict mode forbids introducing new definitions for 'eval', 'arguments', or
|
||||
* for any strict mode reserved keyword.
|
||||
|
|
@ -6023,10 +6008,9 @@ Parser<ParseHandler>::returnStatement(YieldHandling yieldHandling)
|
|||
if (!pn)
|
||||
return null();
|
||||
|
||||
/* Disallow "return v;" in legacy generators. */
|
||||
if (pc->isLegacyGenerator() && exprNode) {
|
||||
/* Disallow "return v;" in legacy generators. */
|
||||
reportBadReturn(pn, ParseError, JSMSG_BAD_GENERATOR_RETURN,
|
||||
JSMSG_BAD_ANON_GENERATOR_RETURN);
|
||||
errorAt(begin, JSMSG_BAD_GENERATOR_RETURN);
|
||||
return null();
|
||||
}
|
||||
|
||||
|
|
@ -6141,8 +6125,7 @@ Parser<ParseHandler>::yieldExpression(InHandling inHandling)
|
|||
)
|
||||
{
|
||||
/* As in Python (see PEP-255), disallow return v; in generators. */
|
||||
reportBadReturn(null(), ParseError, JSMSG_BAD_GENERATOR_RETURN,
|
||||
JSMSG_BAD_ANON_GENERATOR_RETURN);
|
||||
errorAt(begin, JSMSG_BAD_GENERATOR_RETURN);
|
||||
return null();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue