-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
anonymous function as a statement crashes compiler #4617
Comments
I can confirm this is broken. It appears the breaking change happened between v3.18.1 and v3.18.2:
That should help narrow down what happened between the two versions. Version compare for ease: 46634e8...c323282 |
I've been looking into this, and I've tracked down the cause to #4385 which upgraded the version of https://github.com/Rich-Harris/code-red. I believe the crash is happening in code-red, and specifically this commit is what caused it: Rich-Harris/code-red@2ad7c7a I don't understand enough about code-red works to fix it, but hoping that this information will help someone else out. |
Yup, looks like a code-red issue. I've opened Rich-Harris/code-red#38 |
This is fixed now in 3.23.2 - https://svelte.dev/repl/574ed4913495492bb1c9580e1b203de8?version=3.23.2 |
Describe the bug
When an anonymous function is created without being assigned, just as a single statement, it crashes the compiler.
This issue appeared in 3.18.2.
Logs
Stack trace
To Reproduce
https://svelte.dev/repl/574ed4913495492bb1c9580e1b203de8?version=3.20.1
Expected behavior
This useless function must be created but since it's not called, nothing special should happen.
Severity
Honestly it's not very severe. I noticed this issue because I mistakenly forgot to
return
my anonymous function. I don't really see any reason anyone would want to create an anonymous function and never call it.However, it's valid JavaScript so it should either be supported or fail with a more explanatory error: "You are making an anonymous function and never calling it. Are you really sure?". But I would argue this is a linter's job, not svelte.
So I think svelte should just support it.
The text was updated successfully, but these errors were encountered: