fix(emit): 括号包裹的匿名函数参与 name 推断(is_anonymous_function_definition)
This commit is contained in:
@@ -194,12 +194,7 @@ impl Emitter {
|
||||
let val_reg = self.emit_expression(&assign.right, ctx)?;
|
||||
let name = id_ref.name.as_str();
|
||||
// 赋值函数/箭头/class 表达式 → 推断 name。
|
||||
if matches!(
|
||||
&assign.right,
|
||||
oxide_parser::Expression::ArrowFunctionExpression(_)
|
||||
| oxide_parser::Expression::FunctionExpression(_)
|
||||
| oxide_parser::Expression::ClassExpression(_)
|
||||
) {
|
||||
if crate::is_anonymous_function_definition(&assign.right) {
|
||||
if let Some(sub_mod) = ctx.nested.last_mut() {
|
||||
if sub_mod.function_name.is_none() {
|
||||
sub_mod.function_name = Some(name.to_string());
|
||||
|
||||
@@ -5,7 +5,7 @@ use oxide_bytecode::module::Constant;
|
||||
use oxide_bytecode::opcode::OpCode;
|
||||
use oxide_ir::inst::Inst;
|
||||
use oxide_ir::operand::Operand;
|
||||
use oxide_parser::{Expression, ObjectPropertyKind, PropertyKind};
|
||||
use oxide_parser::{ObjectPropertyKind, PropertyKind};
|
||||
|
||||
impl Emitter {
|
||||
pub(crate) fn emit_object_expression(
|
||||
@@ -56,12 +56,7 @@ impl Emitter {
|
||||
reg
|
||||
};
|
||||
let val_reg = self.emit_expression(&p.value, ctx)?;
|
||||
if matches!(
|
||||
&p.value,
|
||||
Expression::ArrowFunctionExpression(_)
|
||||
| Expression::FunctionExpression(_)
|
||||
| Expression::ClassExpression(_)
|
||||
) {
|
||||
if crate::is_anonymous_function_definition(&p.value) {
|
||||
if let Some(sub_mod) = ctx.nested.last_mut() {
|
||||
sub_mod.function_name = Some(prop_name.to_string());
|
||||
}
|
||||
@@ -84,3 +79,4 @@ impl Emitter {
|
||||
Ok(obj_reg)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user