-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default export of anonymous function or class crashes compiler #3275
Comments
Seemingly fixed by: diff --git a/src/compiler/compile/utils/scope.ts b/src/compiler/compile/utils/scope.ts
index 0255ac94..f170060f 100644
--- a/src/compiler/compile/utils/scope.ts
+++ b/src/compiler/compile/utils/scope.ts
@@ -18,7 +18,9 @@ export function create_scopes(expression: Node) {
});
} else if (/Function/.test(node.type)) {
if (node.type === 'FunctionDeclaration') {
- scope.declarations.set(node.id.name, node);
+ if (node.id) {
+ scope.declarations.set(node.id.name, node);
+ }
scope = new Scope(scope, false);
map.set(node, scope);
} else {
@@ -90,7 +92,7 @@ export class Scope {
if (declarator.init) this.initialised_declarations.add(name);
});
});
- } else {
+ } else if (node.id) {
this.declarations.set(node.id.name, node);
}
} I don't know whether this indicates that we're doing something in the wrong order, or whether there are any other situations where we could get to these spots in the code with |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Fixed in 3.39.0. |
Both of these should throw the usual
A component cannot have a default export
error, but instead they are crashing the compiler. The error in each case isTypeError: Cannot read property 'name' of null
but it is coming from a different line.Pretty low priority obviously, but still a bug.
The text was updated successfully, but these errors were encountered: