Svelte 5: snippets with multiple default values get incorrectly parsed
paoloricciuti opened this issue · 0 comments
paoloricciuti commented
Describe the bug
If there's a snippet with multiple default values the parse incorrectly assume everything after the last = is the right argument of the assignment.
Eg.
{#snippet test(a,b=3,c=2)}
{/snippet}
is compiled to
var test = ($$anchor, a = $.noop, $$arg1) => {
let b = $.derived_safe_equal(() => $.value_or_fallback($$arg1?.(), () => (3, c = 2)));
};
that causes a runtime error since c is not defined. You can also check the AST produced to see that the assignment right expression has an assignment expression itself
Reproduction
- go to this repl
- check the compiled code
Logs
No response
System Info
repl
Severity
annoyance