mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-24 02:31:13 +08:00
fix: 解构赋值 rest 目标按 emitter 递归计数,修嵌套 rest 死循环
This commit is contained in:
@@ -77,10 +77,11 @@ impl Compiler {
|
||||
ctx.count_instr(); // STORE_VAR
|
||||
}
|
||||
}
|
||||
if ap.rest.is_some() {
|
||||
if let Some(rest) = &ap.rest {
|
||||
self.count_rest_array(ctx);
|
||||
ctx.alloc_reg();
|
||||
ctx.count_instr(); // STORE_VAR
|
||||
// Mirror the emitter (emit_array_assignment -> emit_assign_target): the rest
|
||||
// target may itself be a nested pattern, not just an identifier.
|
||||
self.count_assign_target(&rest.target, ctx);
|
||||
}
|
||||
ctx.count_instr(); // FOR_OF_CLOSE
|
||||
}
|
||||
@@ -108,11 +109,12 @@ impl Compiler {
|
||||
}
|
||||
}
|
||||
}
|
||||
if op.rest.is_some() {
|
||||
if let Some(rest) = &op.rest {
|
||||
ctx.alloc_reg();
|
||||
ctx.count_instr_with_ext(1); // REST_OBJECT + excluded-keys ext
|
||||
ctx.alloc_reg();
|
||||
ctx.count_instr(); // STORE_VAR
|
||||
// Mirror the emitter (emit_object_assignment -> emit_assign_target): the rest
|
||||
// target may itself be a nested pattern, not just an identifier.
|
||||
self.count_assign_target(&rest.target, ctx);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user