diff options
author | wolfbeast <mcwerewolf@wolfbeast.com> | 2019-04-06 06:54:09 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2019-04-06 06:54:09 +0200 |
commit | 4c4f8091e620a35d6d20a5b0ccc6c118e9b8e5e5 (patch) | |
tree | 41dbe7bfcc8a13cf72e4bfee337b0fb75dbb2f3b /js/src/frontend | |
parent | 7d56f431ccc11f3b5e2e6deec331bd9c7a06cf80 (diff) | |
download | UXP-4c4f8091e620a35d6d20a5b0ccc6c118e9b8e5e5.tar UXP-4c4f8091e620a35d6d20a5b0ccc6c118e9b8e5e5.tar.gz UXP-4c4f8091e620a35d6d20a5b0ccc6c118e9b8e5e5.tar.lz UXP-4c4f8091e620a35d6d20a5b0ccc6c118e9b8e5e5.tar.xz UXP-4c4f8091e620a35d6d20a5b0ccc6c118e9b8e5e5.zip |
Remove Parser::reportBadReturn
Report simpler errors that don't use the offset of a node as location.
Diffstat (limited to 'js/src/frontend')
-rw-r--r-- | js/src/frontend/Parser.cpp | 23 | ||||
-rw-r--r-- | js/src/frontend/Parser.h | 2 |
2 files changed, 3 insertions, 22 deletions
diff --git a/js/src/frontend/Parser.cpp b/js/src/frontend/Parser.cpp index b494cc966..0099ed19d 100644 --- a/js/src/frontend/Parser.cpp +++ b/js/src/frontend/Parser.cpp @@ -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(); } diff --git a/js/src/frontend/Parser.h b/js/src/frontend/Parser.h index efbaebafd..27a10458b 100644 --- a/js/src/frontend/Parser.h +++ b/js/src/frontend/Parser.h @@ -1445,8 +1445,6 @@ class Parser final : private JS::AutoGCRooter, public StrictModeGetter static Node null() { return ParseHandler::null(); } - bool reportBadReturn(Node pn, ParseReportKind kind, unsigned errnum, unsigned anonerrnum); - JSAtom* prefixAccessorName(PropertyType propType, HandleAtom propAtom); TokenPos pos() const { return tokenStream.currentToken().pos; } |