Describe the bug
Svelte 4 slots using inline @const declaration resulting in error at runtime
Cannot access 'index' before initialization
<div slot="item" let:index let:style {style}>
<!-- This results in error: ❌ -->
<!-- `Cannot access 'index' before initialization` -->
{@const item = list[index]}
XOXO: {item}
<!-- This works ✅ -->
XOXO: {list[index]}
</div>
Reproduction
<div slot="item" let:index let:style {style}>
<!-- This works ✅ -->
XOXO: {list[index]}
</div>
Emits:

<div slot="item" let:index let:style {style}>
<!-- This results in error: ❌ -->
<!-- `Cannot access 'index' before initialization` -->
{@const item = list[index]}
XOXO: {item}
</div>
Emits:

Here, const is emitted before any slot variable declaration
Here is an example project:
https://svelte.dev/playground/69d51ef1910347c4823c3e1c201d90f6?version=5.38.0
Logs
Cannot access 'index' before initialization in <unknown> in VList.svelte in App.svelte in
System Info
Severity
blocking an upgrade