Skip to content
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

Svelte 5: Misleading error message "Cannot reassign or bind to each block argument in runes mode." #11084

Closed
felix-roehrich opened this issue Apr 7, 2024 · 2 comments · Fixed by #11168
Milestone

Comments

@felix-roehrich
Copy link

Describe the bug

If you look at the code in the REPL, you will very quickly notice that code in App.svelte will not have the desired effect, but the error message is very confusing, since at no point there is an assignment to an each block element.

Reproduction

https://svelte-5-preview.vercel.app/#H4sIAAAAAAAAE31Qy2rDMBD8lUXtwQYT93kxsmnxJ_QY5eA6ayIqS0JaB4Lwv1eK3Rra0uPOzA4zE9ggFXpW7QPT3YisYq_WsoLRxabDn1ERxtubyfUJ4b530lIjtCA5WuMIWhicGUGwXdnulg_BhOblJtV8wStjSRrtwU0aPZSR4-3VK9x4La1FAtVdzERZgHOnJoQ5nxOfFNj1J9jfFw_FY_FUPB-g86BXVhB_n4iMBqN7JfuPOmQ51M3qUkdh84bEy0XVrJ5l8rxahHINMKfobRNLj-YoB4lHVpGbcC6-N2r_WyiV3TYSpGKnsLaCOSa5tc5Yn-Ub_ZXx7sdq4cWhPqL7Y5Pf8Q7zJ0lZY4POAQAA

Logs

No response

System Info

REPL

Severity

annoyance

@dm-de
Copy link

dm-de commented Apr 7, 2024

I rewrote your code, but it is useless... value does nothing - maybe replace with console.log

LINK

@Rich-Harris Rich-Harris added this to the 5.0 milestone Apr 7, 2024
@MacFJA
Copy link

MacFJA commented Apr 7, 2024

I rewrote your code, but it is useless... value does nothing - maybe replace with console.log

LINK

The rewrite is incorrect, you declare a new variable inside the scope of the function, it's not the same value from the layout, so the code run, but it has no effect in the component C.svelte


The value from a snippet instruction seem to be immutable, similar to getContext/setContext

If it's the case, then maybe the documentation should indicate this limitation, and maybe the same workaround as getContext


So, if, instead of a simple value, a plain old store is used, then the code work as expected (as far as I understand the goal of this code) (See my version with store, I add a <fieldset> that contains the content of value to visualize the changes)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants