Skip to content

Svelte 5.1.13: Reassigning store leads to undefined #14233

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

Closed
kyoshino opened this issue Nov 9, 2024 · 6 comments · Fixed by #14236
Closed

Svelte 5.1.13: Reassigning store leads to undefined #14233

kyoshino opened this issue Nov 9, 2024 · 6 comments · Fixed by #14236
Labels

Comments

@kyoshino
Copy link
Contributor

kyoshino commented Nov 9, 2024

Describe the bug

Svelte 5.1.13, probably #14195, introduced a regression in the store API, breaking my Sveltia UI library and Sveltia CMS. I had to downgrade to 5.1.12 to get rid of the error.

After creating a store with writable and reassigning a new store to the variable, the store changes to undefined.

My code

Reproduction

REPL: Svelte 5.1.12 / Svelte 5.1.13

In Svelte 5.1.13, the console says world if you uncomment style = writable('svelte');

An interesting thing is the problem can be reproduced even before the init function is called. You’ll notice that the REPL doesn’t call the function.

Logs

No response

System Info

-

Severity

blocking an upgrade

@dummdidumm dummdidumm added the bug label Nov 9, 2024
@paoloricciuti
Copy link
Member

Uh it probably needs more check before treating it as state (right now is treating style as state which is wrong

@dummdidumm
Copy link
Member

The discrepancy is that the initializer does not treat it as state but the reassignment is

@paoloricciuti
Copy link
Member

The discrepancy is that the initializer does not treat it as state but the reassignment is

But it shouldn't be treated as state at all in this case

@kyoshino
Copy link
Contributor Author

kyoshino commented Nov 9, 2024

In my case, working around the problem should be easy and the codebase has already been upgraded to Svelte 5, so it’s actually not blocking upgrade but a breaking change 😅

@paoloricciuti
Copy link
Member

In my case, working around the problem should be easy and the codebase has already been upgraded to Svelte 5, so it’s actually not blocking upgrade but a breaking change 😅

I mean it's a bug not really a breaking change. Will fix asap 😁

@paoloricciuti
Copy link
Member

@dummdidumm I've yet to be able to be at the keyboard but I have the reasonable suspect that we just need to add a check for runes mode.

Because basically in rune mode you would never set the kind to state unless it has a $state init (and in that case it would already be state)

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

Successfully merging a pull request may close this issue.

3 participants