Closed
Description
Describe the bug
Compiler throw an error when using a IIFE as the key in {#each}.
Svelte version: 3.7.1
Logs
TypeError: Cannot set property 'maintain_context' of undefined
at Expression.render (/orbit/node_modules/svelte/compiler.js:21143:37)
at EachBlockWrapper.render_keyed (/orbit/node_modules/svelte/compiler.js:14591:23)
at EachBlockWrapper.render (/orbit/node_modules/svelte/compiler.js:14510:19)
at fragment.nodes.forEach (/orbit/node_modules/svelte/compiler.js:15757:24)
at Array.forEach (<anonymous>)
at ElementWrapper.render (/orbit/node_modules/svelte/compiler.js:15756:34)
at FragmentWrapper.render (/orbit/node_modules/svelte/compiler.js:17432:28)
at new Renderer (/orbit/node_modules/svelte/compiler.js:17463:24)
at dom (/orbit/node_modules/svelte/compiler.js:17662:23)
at compile (/orbit/node_modules/svelte/compiler.js:23840:16)
To Reproduce
Reproducible in REPL:
<script>
const arr = [1, 2, 3]
</script>
<div>
{#each arr as item ((() => item)())}
{item}
{/each}
</div>
This error can be worked around by passing arguments into the IFFE:
<script>
const arr = [1, 2, 3]
</script>
<div>
{#each arr as item (((item) => item)(item))}
{item}
{/each}
</div>
Expected behavior
Compile as is or just disable IIFE usage as key.
Severity
Minor, not a case usual developers would encounter.