Skip to content

Runes mode: Binding in each loop not working #14702

@ralphdelfs

Description

@ralphdelfs

Describe the bug

In runes mode, when iterating an array of objects in an each loop, it is not possible to bind the object to a component.

<svelte:options runes={true} />
<script>
	import Component from "./Component.svelte"
	
	let objs = [{
		val: "foo"
	}]
</script>

{#each objs as obj}
  <Component bind:obj />
{/each}

Error each_item_invalid_assignment is raised. This works fine when runes mode is disabled.

Reproduction

https://svelte.dev/playground/71e6da2a2afd4a5e812bdd7263e5c7dd?version=5.12.0

Logs

Cannot reassign or bind to each block argument in runes mode. Use the array and index variables instead (e.g. `array[i] = value` instead of `entry = value`)
https://svelte.dev/e/each_item_invalid_assignment

System Info

svelte 5.12.0, see repl

Severity

blocking an upgrade

Metadata

Metadata

Assignees

No one assigned

    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