-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Closed
Description
Describe the bug
When declaring snippets with the same name inside separate component slots, you get a compiler error for '<name>' has already been declared, even though they shouldn't be sharing the same scope.
e.g.
<script>
import Box from './Box.svelte';
</script>
<Box>
{#snippet children()}
Hello
{/snippet}
</Box>
<Box>
{#snippet children()}
World
{/snippet}
</Box>The second children snippet gives an error of 'children' has already been declared, even though each snippet should have their own respective scope.
Workaround for now is creating the snippet with a different name, and passing it as a prop to the component.
e.g.
<Box>
{#snippet children()}
Hello
{/snippet}
</Box>
<Box children={children2}>
{#snippet children2()}
World
{/snippet}
</Box>Reproduction
Logs
index-a870eda6.js:83 CompileError: 'children' has already been declared
at ar (compiler.cjs@5.0.0-next.17:1:228250)
at Ys.declare (compiler.cjs@5.0.0-next.17:1:301114)
at SnippetBlock (compiler.cjs@5.0.0-next.17:1:306484)
at e (compiler.cjs@5.0.0-next.17:1:112918)
at visit (compiler.cjs@5.0.0-next.17:1:112780)
at Component (compiler.cjs@5.0.0-next.17:1:303836)
at e (compiler.cjs@5.0.0-next.17:1:112918)
at eval (compiler.cjs@5.0.0-next.17:1:112560)
at Array.forEach (<anonymous>)
at Object.next (compiler.cjs@5.0.0-next.17:1:112509)System Info
REPL Chrome
Severity
annoyance
Metadata
Metadata
Assignees
Labels
No labels