fix(emit): 括号包裹的匿名函数参与 name 推断(is_anonymous_function_definition)

This commit is contained in:
爱特每羊队
2026-08-07 20:27:49 +08:00
parent b64849cdb0
commit fec6b68ecb
6 changed files with 21 additions and 27 deletions
+12
View File
@@ -13,6 +13,18 @@ use oxide_ir::inst::Inst;
use oxide_ir::operand::{LabelId, Operand};
use oxide_ir::IRFunction;
/// 是否为匿名函数定义(剥括号):函数/箭头/class 表达式。
pub fn is_anonymous_function_definition(expr: &oxide_parser::Expression) -> bool {
match expr {
oxide_parser::Expression::ArrowFunctionExpression(_)
| oxide_parser::Expression::FunctionExpression(_)
| oxide_parser::Expression::ClassExpression(_) => true,
oxide_parser::Expression::ParenthesizedExpression(p) => is_anonymous_function_definition(&p.expression),
_ => false,
}
}
use crate::emit_ctx::{LabelCtx, ScopeCtx};
use crate::symbol_table::{Binding, ScopeKind, SymbolTable};