Issue #2213 - Follow-up: Fix derieved Generator prototypes after previous change

This commit is contained in:
Martok 2023-04-26 22:03:06 +02:00 • committed by roytam1
commit a27e8bf989
2 changed files with 6 additions and 1 deletions

View file

@ -179,6 +179,8 @@ GeneratorObject::resume(JSContext* cx, InterpreterActivation& activation,
{
Rooted<GeneratorObject*> genObj(cx, &obj->as<GeneratorObject>());
MOZ_ASSERT(genObj->isSuspended());
// See comment in InterpreterStack::resumeGeneratorCallFrame
MOZ_ASSERT_IF(genObj->isConstructing(), genObj->is<LegacyGeneratorObject>());
RootedFunction callee(cx, &genObj->callee());
RootedValue newTarget(cx, genObj->newTarget());

View file

@ -351,7 +351,10 @@ InterpreterStack::resumeGeneratorCallFrame(JSContext* cx, InterpreterRegs& regs,
constructing = MaybeConstruct(newTarget.isObject());
MOZ_ASSERT_IF(constructing, callee->isConstructor());
} else {
MOZ_ASSERT(!callee->isConstructor());
// We should really be doing MOZ_ASSERT(!callee->isConstructor()) here.
// However, the GeneratorObject only stores the callee as-is, which in the case of a lambda generator
// (i.e. a |new GeneratorFunction(...)| or derieved generator class) is still flagged as a constructor.
// Instead, we check for the correct state in GeneratorObject::resume.
}
// Include callee, |this|, and maybe |new.target|