diff --git a/crates/oxide_emit/src/stmt/exception/try_catch.rs b/crates/oxide_emit/src/stmt/exception/try_catch.rs index 654cacf..dffcff9 100644 --- a/crates/oxide_emit/src/stmt/exception/try_catch.rs +++ b/crates/oxide_emit/src/stmt/exception/try_catch.rs @@ -47,11 +47,10 @@ impl Emitter { if let Some(catch) = &ts.handler { ctx.push_scope(); if let Some(param) = &catch.param { - let catch_reg = ctx.alloc_reg(); - if let oxide_parser::BindingPattern::BindingIdentifier(bi) = ¶m.pattern { - ctx.declare_initialized(bi.name.as_str(), catch_reg, VariableDeclarationKind::Let, false)?; - ctx.inst(Inst::new(OpCode::STORE_VAR, Operand::Reg(catch_reg), Operand::None, Operand::None)); - } + let src_reg = ctx.alloc_reg(); + // 异常值在 VM 物理 regs[0](unwind 展开处写入),STORE_VAR a=None 读回。 + ctx.inst(Inst::new(OpCode::STORE_VAR, Operand::Reg(src_reg), Operand::None, Operand::None)); + self.emit_binding_pattern(¶m.pattern, src_reg, VariableDeclarationKind::Let, false, ctx)?; } let mut last_catch_result: Option = None; for s in &catch.body.body {