fix: 全量单测修复(flatten 健壮性 + 测试链路补 flatten + 断言对齐规范)

This commit is contained in:
爱特每羊队
2026-08-08 16:03:24 +08:00
parent 6e5bbe718b
commit 3a8bf56a68
6 changed files with 25 additions and 17 deletions
+2 -1
View File
@@ -23,7 +23,8 @@ fn assign_ids(module: &mut CompiledModule, next_id: &mut u32) {
for instr in &mut module.bytecode {
if opcode::opcode(*instr) == OpCode::CREATE_CLOSURE {
let rel = opcode::imm16(*instr) as usize;
let flat = module.sub_modules.get(rel - 1).map(|s| s.flat_id).unwrap_or(0);
// rel 应为 1-based 子模块下标;0 表示无引用(异常输入),按未解析处理。
let flat = if rel > 0 { module.sub_modules.get(rel - 1).map(|s| s.flat_id).unwrap_or(0) } else { 0 };
let rd = opcode::rd(*instr);
*instr = opcode::encode(
OpCode::CREATE_CLOSURE,