mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-05 06:32:30 +02:00
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:
committed by
Andreas Kling
parent
52ee05cb5d
commit
d3a295a1e1
Notes:
github-actions[bot]
2026-02-21 18:28:05 +00:00
Author: https://github.com/awesomekling Commit: https://github.com/LadybirdBrowser/ladybird/commit/d3a295a1e18 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/8065
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user