svelte: Svelte 5: unable to name a variable with the "same name" as a rune

Describe the bug

When naming a variable with the same name as a rune, without the $, like state or derived or others, the compiler considers them as the same, thus leading to errors like Cannot access 'state' before initialization or errors relating to rune re-affectation.

Even if it’s not a bug, runes re-affectation should be prohibited.

Reproduction

https://svelte-5-preview.vercel.app/#H4sIAAAAAAAACj2N0QqDMAxFfyUEH9wQHHsaVQf7jrkH10ZWqG1pU2GI_z46N99yT3JPFhy1oYjivqAdJkKBN--xQn77HOJMhgkrjC4FmUm7IeE8a2cjhGQpQn3tbW_bKIP2nGc2xCBdsgwdFJEHpvJ0aPJGOhsZvgg6uGS2U0VBz6Sggx5fZIzrsfnblEtPkyvF76rc_Ec4Z3Fb79-xwskpPWpSKDgkWh_rB8K78zLqAAAA

Logs

No response

System Info

REPL, Svelte 5 next 175

Severity

annoyance

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 1
  • Comments: 23 (13 by maintainers)

Most upvoted comments

This works as expected. We decided to give stores precedence over runes in this situation. We can revisit this decision in Svelte 6.

There is already a warning for this problem, as you can see in the REPL.