fix: Promise.prototype.then 按构造器建派生能力支持子类

This commit is contained in:
2026-08-15 22:16:05 +08:00
parent 26db7ae07c
commit 3a40024e99
5 changed files with 326 additions and 43 deletions
+5 -3
View File
@@ -447,9 +447,11 @@ impl Vm {
}
}
}
// 生成器/异步内嵌 dispatch:帧全部弹出后把结果交付恢复方,而非继续执行。
if self.frames.is_empty() && (self.generator_dispatch || self.async_dispatch) {
return Ok(Some(result));
// 生成器/异步/构造内嵌 dispatch:帧全部弹出后把结果交付恢复方,而非继续执行。
if self.frames.is_empty() && (self.generator_dispatch || self.async_dispatch || self.construct_dispatch) {
// 构造内嵌:弹帧已把构造结果(非对象回退 this)写入 regs[0],直接交付。
let delivered = if self.construct_dispatch { self.regs[0] } else { result };
return Ok(Some(delivered));
}
Ok(None)
} else {