From fbb5f73459d081bc31f2c64539c4aabd02ab962c Mon Sep 17 00:00:00 2001 From: Martok Date: Wed, 15 Mar 2023 10:29:12 +0100 Subject: [PATCH] Issue #2155 - Fix wrong assertion (x) = function() {..} is an extremely sparsely documented way to prevent function name inference. Modeled after how BytecodeEmitter::emitInitializer does it. --- js/src/frontend/BytecodeEmitter.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/js/src/frontend/BytecodeEmitter.cpp b/js/src/frontend/BytecodeEmitter.cpp index ebca1db924..4b80a99669 100644 --- a/js/src/frontend/BytecodeEmitter.cpp +++ b/js/src/frontend/BytecodeEmitter.cpp @@ -3784,7 +3784,7 @@ BytecodeEmitter::emitNameIncDec(ParseNode* incDec) ParseNodeKind kind = incDec->getKind(); NameNode* name = &incDec->pn_kid->as(); - NameOpEmitter noe(this, name->atom(), + NameOpEmitter noe(this, name->pn_atom, kind == PNK_POSTINCREMENT ? NameOpEmitter::Kind::PostIncrement : kind == PNK_PREINCREMENT ? NameOpEmitter::Kind::PreIncrement : kind == PNK_POSTDECREMENT ? NameOpEmitter::Kind::PostDecrement @@ -5838,8 +5838,8 @@ BytecodeEmitter::emitAssignment(ParseNode* lhs, JSOp compoundOp, ParseNode* rhs) if (!EmitAssignmentRhs(this, rhs, offset)) { // ENV? VAL? RHS return false; } - if (rhs && rhs->isDirectRHSAnonFunction()) { - MOZ_ASSERT(!lhs->isInParens()); + // Assign inferred function name, unless the lhs is parenthesized + if (rhs && rhs->isDirectRHSAnonFunction() && !lhs->isInParens()) { MOZ_ASSERT(!isCompound); RootedAtom name(cx, lhs->name()); if (!setOrEmitSetFunName(rhs, name)) { // ENV? VAL? RHS