Skip to content

Svelte 5: snippets with multiple default values get incorrectly parsed #12067

Closed
@paoloricciuti

Description

@paoloricciuti

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions