Skip to content
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

if/else regression in 3.9.2 #3505

Closed
burningTyger opened this issue Sep 4, 2019 · 3 comments · Fixed by #3518
Closed

if/else regression in 3.9.2 #3505

burningTyger opened this issue Sep 4, 2019 · 3 comments · Fixed by #3518
Labels

Comments

@burningTyger
Copy link
Contributor

Describe the bug
{#if "Eva".startsWith('E')}
eee
{:else}
rrr
{/if}

will throw an error

To Reproduce
https://svelte.dev/repl/60ba4405814042e4925edc98e3bcc797?version=3.9.2

Expected behavior
no error

Stacktraces
Rollup: Unexpected token (Note that you need

Severity
breaking change

@Conduitry
Copy link
Member

This appeared in 3.9.1, and apparently #3478 in 3.9.2 was an incomplete fix.

@Conduitry Conduitry added the bug label Sep 4, 2019
@J-IN
Copy link

J-IN commented Sep 5, 2019

This seems to be caused by an empty dependencies array in IfBlocks.ts file, generated code is

if ((show_if == null) || ) show_if = !!("Eva".startsWith('E') == true)

Updating line 246 to check the array length should fix this issue :

${snippet && `if ((${condition} == null) || ${dependencies.length > 0 ? dependencies.map(n => `changed.${n}`).join(' || ') : false}) ${condition} = !!(${snippet})`}

generating code :

if ((show_if == null) || false) show_if = !!("Eva".startsWith('E') == true)

@burningTyger
Copy link
Contributor Author

🙌

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

Successfully merging a pull request may close this issue.

3 participants