Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
paoloricciuti opened this issue Jun 17, 2024 · 0 comments · Fixed by #12070
Closed

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

paoloricciuti opened this issue Jun 17, 2024 · 0 comments · Fixed by #12070
Assignees

Comments

@paoloricciuti
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants