fix: 变量声明完成值归空记录,脚本保留末非空完成值

This commit is contained in:
2026-09-14 20:15:08 +00:00
parent 53da6ef817
commit fa67988ab4
3 changed files with 8 additions and 8 deletions
+4 -3
View File
@@ -1874,9 +1874,10 @@ impl Emitter {
if matches!(stmt, Statement::FunctionDeclaration(_)) {
continue; // Already emitted above
}
match self.emit_statement(stmt, &mut ctx)? {
Some(r) => last_result = Some(r),
None => last_result = None,
// 空完成值语句(变量/函数等声明)不覆写此前结果:保留最后一个非空
// 完成值,与函数体 emit_body_stmts 的收敛口径一致。
if let Some(r) = self.emit_statement(stmt, &mut ctx)? {
last_result = Some(r);
}
}
if let Some(r) = last_result {