mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-24 02:31:13 +08:00
fix: 赋值表达式与对象属性函数名推断(function/class/arrow)
This commit is contained in:
@@ -193,6 +193,19 @@ impl Emitter {
|
||||
} else {
|
||||
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 let Some(sub_mod) = ctx.nested.last_mut() {
|
||||
if sub_mod.function_name.is_none() {
|
||||
sub_mod.function_name = Some(name.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
// 目标若是 upvalue 引用,走 STORE_UPVALUE
|
||||
if let Some(uv_idx) = ctx.current_upvalue_captures.iter().position(|u| u.name == name) {
|
||||
ctx.inst(Inst::new(
|
||||
|
||||
@@ -56,7 +56,12 @@ impl Emitter {
|
||||
reg
|
||||
};
|
||||
let val_reg = self.emit_expression(&p.value, ctx)?;
|
||||
if matches!(&p.value, Expression::ArrowFunctionExpression(_)) {
|
||||
if matches!(
|
||||
&p.value,
|
||||
Expression::ArrowFunctionExpression(_)
|
||||
| Expression::FunctionExpression(_)
|
||||
| Expression::ClassExpression(_)
|
||||
) {
|
||||
if let Some(sub_mod) = ctx.nested.last_mut() {
|
||||
sub_mod.function_name = Some(prop_name.to_string());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user