sveltejs/svelte

Svelte 5: snippets with multiple default values get incorrectly parsed

paoloricciuti opened this issue · 0 comments

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
image

Reproduction

  1. go to this repl
  2. check the compiled code

Logs

No response

System Info

repl

Severity

annoyance