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: compilation error when referencing shadowed state #13314

Closed
trueadm opened this issue Sep 18, 2024 · 0 comments · Fixed by #13316
Closed

Svelte 5: compilation error when referencing shadowed state #13314

trueadm opened this issue Sep 18, 2024 · 0 comments · Fixed by #13316
Labels
Milestone

Comments

@trueadm
Copy link
Contributor

trueadm commented Sep 18, 2024

Describe the bug

Given this use test case:

<script>
  const { count } = $props();

  let local = $derived.by(() => {
    const local = $state({ count })

    return local;
  });
</script>

<div>Local: {local.count}</div>

You can see the compiled output for the return local is incorrectly return $.get(local); This is because we are shadowing the local binding.

This means that we then push the state object into the dependencies for the derived signal causing everything to crash to a halt.

Reproduction

Repro case

@trueadm trueadm added the bug label Sep 18, 2024
@trueadm trueadm added this to the 5.0 milestone Sep 18, 2024
@trueadm trueadm changed the title Svelte 5: compilation error when referencing local state Svelte 5: compilation error when referencing shadowed state Sep 18, 2024
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.

1 participant