Skip to content

Svelte 5: Error: x is not defined #9400

@98mux

Description

@98mux

Describe the bug

This code:

<script>
		let arr = $state([1,2,3]);
</script>

{#each arr as value}
        <button onclick={() => value += 1}>Click me and get error</button>
{/each}

causes the error "Error: arr is not defined"
When clicking on the button.

No idea if this has been posted before or not

Reproduction

https://svelte-5-preview.vercel.app/#H4sIAAAAAAAAA0WOQQ6CMBBFrzKpLiCSEHSHQGI8BmVRy6iNpSXtQGIa7m4RE2f3Z97k_cDuSqNnZRuYEQOykl3GkWWM3uMa_IyaMGZvJyfXTeWlUyM13HDipJFAOAc17D0JwqQtsmN26tIzN1X-R03YoZDPLys8zEJPuHADv6luE5E1YI3USr7qkKRQNxsGhxqKpbmuBxgQhOnhEbXonHVVvn1GR8hXwxK7DrZXd4U9K8lFTbd8AOl8PbvmAAAA

Logs

No response

System Info

repl

Severity

annoyance

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions