Skip to content

migrate: incorrect parenthesis handling in derived expressions #13278

@Azarattum

Description

@Azarattum

Describe the bug

Originally discovered here: #13250 (comment).

Auto-migration generates invalid code when a reactive $: variable is assigned to an expression in parenthesis. So, when trying to process:

$: double = (console.log(double), count * 2); 

it outputs

let double = ($derived(console.log(double), count * 2); 

which is obviously wrong. Parenthesis are mismatched and put in the wrong places. The compiler gives:

Error compiling App.svelte
Unexpected token

Reproduction

https://svelte-5-preview.vercel.app/#H4sIAAAAAAAAAy3MywrCMBCF4VcZBhetBBWX6QV8DuNC06kE0kxIJoKUvrsEuzwfh3_F2XnKqO8rhudCqPEWIyqUb6wjf8gLocLMJdkqfbbJRRlNMOJJwHIJAgNcuioHDROXlycYoLEcMns6eX43f23V_j_Cte3AhP6851DhwpObHU2oJRXaHtsPMpMRYp0AAAA=

Logs

No response

System Info

N/A

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