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: Store auto-subscriptions cause inconsistent variable shadowing. #11144

Closed
brunnerh opened this issue Apr 12, 2024 · 0 comments · Fixed by #11170
Closed

Svelte 5: Store auto-subscriptions cause inconsistent variable shadowing. #11144

brunnerh opened this issue Apr 12, 2024 · 0 comments · Fixed by #11170

Comments

@brunnerh
Copy link
Member

Describe the bug

This is a bit of a corner case:
If there is a variable shadowing a (top-level) store, this will either result in an error or not depending on whether an auto-subscription has been created elsewhere.

Reproduction

<script>
	import { writable } from 'svelte/store';
	const user = writable(0);
	const users = [];
	$: selected = users.find(user => user.id == $user);

	// Remove to get error:
	$: console.log($user);
</script>

Svelte 5
Svelte 4 - Always errors as I would have expected

Logs

No response

System Info

REPL - Svelte v5.0.0-next.100

Severity

annoyance

@brunnerh brunnerh changed the title Store auto-subscriptions cause inconsistent variable shadowing. Svelte 5: Store auto-subscriptions cause inconsistent variable shadowing. Apr 12, 2024
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.

1 participant