fix: class 类名绑定经 dedicated cell 捕获(C===Cv 恒等)+ upvalue 写入 const guard(getter 赋值抛 TypeError)

This commit is contained in:
爱特每羊队
2026-08-12 17:30:28 +08:00
parent 1323a0564b
commit 86a20fa1fe
10 changed files with 60 additions and 31 deletions
+6 -1
View File
@@ -323,7 +323,8 @@ impl Vm {
}
#[allow(dead_code)]
pub(crate) fn dispatch_store_upvalue(&mut self, a: usize, b: usize) -> Result<(), String> {
pub(crate) fn dispatch_store_upvalue(&mut self, rd: usize, a: usize, b: usize) -> Result<(), String> {
let const_flag = rd;
let uv_idx = b;
let src_val = self.regs[a];
if let Some(callee) = self.current_callee() {
@@ -334,6 +335,10 @@ impl Vm {
if !upvals[uv_idx].is_null() {
unsafe {
let cell = &mut *upvals[uv_idx];
if const_flag != 0 && !cell.value.is_undefined() {
self.raise_error_kind("TypeError", "Assignment to constant variable")?;
return Ok(());
}
cell.value = src_val;
cell.set_initialized(true);
}
+1 -1
View File
@@ -1244,7 +1244,7 @@ impl Vm {
self.dispatch_load_upvalue(rd, instr)?;
}
OpCode::STORE_UPVALUE => {
self.dispatch_store_upvalue(a, b)?;
self.dispatch_store_upvalue(rd, a, b)?;
}
OpCode::CREATE_REGEXP => match self.dispatch_create_regexp(rd, a, b) {
Ok(Some(result)) => return Ok(result),