fix: directive 序言字符串按源序先发射且完成值参与收敛

This commit is contained in:
2026-09-14 21:07:10 +00:00
parent 647fb31af7
commit ca5c27574e
3 changed files with 12 additions and 1 deletions
+5
View File
@@ -365,6 +365,11 @@ impl Emitter {
}
// —— body(函数声明 hoisting 先发,随后其余;import 已由 prelude 处理)——
// directive 序言是 AST 独立字段(顶格字符串字面量,不在 body):纯字符串
// 无副作用,按源序先于 body 发射,与脚本 emit_program 的发射口径一致。
for dir in &program.directives {
self.emit_string_literal_expression(&dir.expression, ctx)?;
}
for stmt in body {
if is_hoisted_function_decl(stmt) {
self.emit_statement(stmt, ctx)?;