mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 16:45:03 +00:00
Only apply auto-naming of function expressions based on syntax
The auto naming of function expressions is a purely syntactic decision, so shouldn't be decided based on the dynamic type of an assignment. This moves the decision making into the parser. One icky hack is that we add a field to FunctionExpression to indicate whether we can autoname. The real solution is to actually generate a CompoundExpression node so that the parser can make the correct decision, however this would have a potentially significant run time cost. This does not correct the behaviour for class expressions. Patch from Anonymous.
This commit is contained in:
@@ -1429,10 +1429,6 @@ Value AssignmentExpression::execute(Interpreter& interpreter, GlobalObject& glob
|
||||
return {};
|
||||
}
|
||||
|
||||
// FIXME: We should also check if the LHS is an identifier reference.
|
||||
if (rhs_result.is_function())
|
||||
update_function_name(rhs_result, get_function_name(global_object, reference.name().to_value(interpreter.vm())));
|
||||
|
||||
reference.put(global_object, rhs_result);
|
||||
|
||||
if (interpreter.exception())
|
||||
@@ -1573,7 +1569,8 @@ Value VariableDeclaration::execute(Interpreter& interpreter, GlobalObject& globa
|
||||
if (interpreter.exception())
|
||||
return {};
|
||||
auto variable_name = declarator.id().string();
|
||||
update_function_name(initalizer_result, variable_name);
|
||||
if (is<ClassExpression>(*init))
|
||||
update_function_name(initalizer_result, variable_name);
|
||||
interpreter.vm().set_variable(variable_name, initalizer_result, global_object, true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user