diff options
Diffstat (limited to 'js/src/frontend/Parser.cpp')
-rw-r--r-- | js/src/frontend/Parser.cpp | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/js/src/frontend/Parser.cpp b/js/src/frontend/Parser.cpp index bcd6c30c02..5cb47f2425 100644 --- a/js/src/frontend/Parser.cpp +++ b/js/src/frontend/Parser.cpp @@ -2472,6 +2472,11 @@ GeneralParser<ParseHandler, Unit>::functionBody(InHandling inHandling, } } + if (pc_->numberOfArgumentsNames > 0 || kind == FunctionSyntaxKind::Arrow) { + MOZ_ASSERT(pc_->isFunctionBox()); + pc_->sc()->setIneligibleForArgumentsLength(); + } + // Declare the 'arguments', 'this', and 'new.target' bindings if necessary // before finishing up the scope so these special bindings get marked as // closed over if necessary. Arrow functions don't have these bindings. @@ -6570,6 +6575,8 @@ bool GeneralParser<ParseHandler, Unit>::forHeadStart( return false; } } + } else if (handler_.isArgumentsLength(*forInitialPart)) { + pc_->sc()->setIneligibleForArgumentsLength(); } else if (handler_.isPropertyOrPrivateMemberAccess(*forInitialPart)) { // Permitted: no additional testing/fixup needed. } else if (handler_.isFunctionCall(*forInitialPart)) { @@ -7917,7 +7924,12 @@ bool GeneralParser<ParseHandler, Unit>::finishClassConstructor( bool hasPrivateBrand = classInitializedMembers.hasPrivateBrand(); if (hasPrivateBrand || numMemberInitializers > 0) { // Now that we have full set of initializers, update the constructor. - MemberInitializers initializers(hasPrivateBrand, numMemberInitializers); + MemberInitializers initializers( + hasPrivateBrand, +#ifdef ENABLE_DECORATORS + classInitializedMembers.hasInstanceDecorators, +#endif + numMemberInitializers); ctorbox->setMemberInitializers(initializers); // Field initialization need access to `this`. @@ -10220,6 +10232,8 @@ typename ParseHandler::NodeResult GeneralParser<ParseHandler, Unit>::assignExpr( return errorResult(); } } + } else if (handler_.isArgumentsLength(lhs)) { + pc_->sc()->setIneligibleForArgumentsLength(); } else if (handler_.isPropertyOrPrivateMemberAccess(lhs)) { // Permitted: no additional testing/fixup needed. } else if (handler_.isFunctionCall(lhs)) { @@ -10280,6 +10294,8 @@ bool GeneralParser<ParseHandler, Unit>::checkIncDecOperand( return false; } } + } else if (handler_.isArgumentsLength(operand)) { + pc_->sc()->setIneligibleForArgumentsLength(); } else if (handler_.isPropertyOrPrivateMemberAccess(operand)) { // Permitted: no additional testing/fixup needed. } else if (handler_.isFunctionCall(operand)) { @@ -10898,6 +10914,9 @@ template <class ParseHandler> inline typename ParseHandler::NameNodeResult PerHandlerParser<ParseHandler>::newName(TaggedParserAtomIndex name, TokenPos pos) { + if (name == TaggedParserAtomIndex::WellKnown::arguments()) { + this->pc_->numberOfArgumentsNames++; + } return handler_.newName(name, pos); } @@ -10926,6 +10945,13 @@ GeneralParser<ParseHandler, Unit>::memberPropertyAccess( MOZ_ASSERT(!handler_.isSuperBase(lhs)); return handler_.newOptionalPropertyAccess(lhs, name); } + + if (handler_.isArgumentsName(lhs) && handler_.isLengthName(name)) { + MOZ_ASSERT(pc_->numberOfArgumentsNames > 0); + pc_->numberOfArgumentsNames--; + return handler_.newArgumentsLength(lhs, name); + } + return handler_.newPropertyAccess(lhs, name); } @@ -11484,6 +11510,10 @@ void GeneralParser<ParseHandler, Unit>::checkDestructuringAssignmentName( return; } + if (handler_.isArgumentsLength(name)) { + pc_->sc()->setIneligibleForArgumentsLength(); + } + if (pc_->sc()->strict()) { if (handler_.isArgumentsName(name)) { if (pc_->sc()->strict()) { @@ -12143,6 +12173,10 @@ GeneralParser<ParseHandler, Unit>::objectLiteral(YieldHandling yieldHandling, } } + if (handler_.isArgumentsLength(lhs)) { + pc_->sc()->setIneligibleForArgumentsLength(); + } + Node rhs; MOZ_TRY_VAR(rhs, assignExpr(InAllowed, yieldHandling, TripledotProhibited)); |