-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Fix rvalue error when using arrow functions in {@const} #7206
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
Comments
The compiler seems to be getting confused by the overlapping scope of the variables with the same name. This works fine cc @baseballyama might know more about the changes needed to fix it. |
Thanks @gtm-nayan! I'll use that as a workaround in the meantime, but I hope we can get this sorted out. |
For now, the compiler gets confused if you declare a variable in If the same variable as in the I will fix it over the next weekend, but until then I will consider for more missing considerations. (Of course, others are welcome to send PRs more quickly!) |
@baseballyama I may have misunderstood you, but in this case it's an object ( |
You are right.
|
@baseballyama Oh dear, that's most definitely a typo from me. I updated the REPL now: https://svelte.dev/repl/2932dbf792f54f9ab5c7f8365e640905?version=3.46.3
The error then becomes |
Thanks for the suggestion! I'm not sure about it until I actually modify the code, but personally I prefer to always declare However, if that is not possible for some reason, then I guess we will implement it as your suggestion. I think the previous fix contains a flaw for AST parsing process, and I think we can fix it by improving that process. |
Describe the bug
When creating a markup variable with {@const}, whose value uses an arrow function in some way (for example, finding an item in an array), Svelte will fail with the error:
Assigning to rvalue (Note that you need plugins to import files that are not JavaScript)
This does not happen in version 3.46.2, but does happen in version 3.46.3. Can be verified by modifying the version string in the reproduction url.
There was recently an arrow function related error reported in #7134 - it seems related.
Reproduction
https://svelte.dev/repl/2932dbf792f54f9ab5c7f8365e640905?version=3.46.3
Logs
System Info
Severity
blocking an upgrade
The text was updated successfully, but these errors were encountered: