LibJS: Fix export default of parenthesized named class expression

For `export default (class Name { })`, two things were wrong:

The parser extracted the class expression's name as the export's
local binding name instead of `*default*`. Per the spec, this is
`export default AssignmentExpression ;` whose BoundNames is
`*default*`, not the class name.

The bytecode generator had a special case for ClassExpression that
skipped emitting InitializeLexicalBinding for named classes.

These two bugs compensated for each other (no crash, but wrong
behavior). Fix both: always use `*default*` as the local binding
name for expression exports, and always emit InitializeLexicalBinding
for the `*default*` binding.
This commit is contained in:
Andreas Kling
2026-02-21 16:20:36 +01:00
committed by Andreas Kling
parent 52ee05cb5d
commit d3a295a1e1
Notes: github-actions[bot] 2026-02-21 18:28:05 +00:00
4 changed files with 13 additions and 18 deletions

View File

@@ -4436,12 +4436,6 @@ NonnullRefPtr<ExportStatement const> Parser::parse_export_statement(Program& pro
if (!special_case_declaration_without_name)
consume_or_insert_semicolon();
if (is<ClassExpression>(*expression)) {
auto const& class_expression = static_cast<ClassExpression const&>(*expression);
if (class_expression.has_name())
local_name = class_expression.name();
}
} else {
expected("Declaration or assignment expression");
local_name = "!!invalid!!"_utf16_fly_string;