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

Using function in IF condition statement fails on 3.16.4 if <svelte:self> is present #4120

Closed
goosechaser opened this issue Dec 17, 2019 · 4 comments · Fixed by #4102
Closed

Comments

@goosechaser
Copy link

goosechaser commented Dec 17, 2019

Describe the bug

This following condition will fail on 3.16.4 (works on earlier versions)

{#if foo && someFunction(foo)}
    <svelte:self />
{/if}

To Reproduce
Broken: REPL
Working: REPL

Severity
Blocking an upgrade. I use recursion a lot in my application.

Additional context
According to @halfnelson on Discord:

function select_block_type(ctx, dirty) {
    if (dirty[0] & /*data*/ 1) show_if = !!(/*datum*/ ctx[1].foo && a(func));
    if (show_if) return 0;
    return 1;
}

1 being passed for "dirty"
then dirty[0] being called
the rest of the changes in output code are all the same, dirty & 1 becoming dirty[0] & 1
@ghost
Copy link

ghost commented Dec 17, 2019

I will try this code with #4102 applied and see if it makes a difference. We lost destructuring as a result of trying to fix some other update cases... maybe it also had the side effect of messing this up.

EDIT: Confirmed fixed if #4102 is merged.

@dekdevy
Copy link

dekdevy commented Dec 17, 2019

Getting the same issue. Does not seem to be related to <svelte:self /> for me. No Repl, but maybe it helps.

{#if $a && $a.b.c=== 'test'}
          {#if $a.d.e()}
            <SomeComponent/>
          {:else}
            <span>This branch is always reached, even if the condition should resolve as true</span>
          {/if}
{:else}
        <span></span>
 {/if}

@ghost
Copy link

ghost commented Dec 17, 2019

@dekdevy,

Thanks, here's a simplified version that still fails:
https://svelte.dev/repl/5bb3f6c7f50c401abbfc6c0f70038884?version=3.16.4

I'll make a test for it and see if the PR fixes it.
This case is also fixed by the referenced PR.

Check the mentioned issue for another case where it fails.

tanhauhau pushed a commit to tanhauhau/svelte that referenced this issue Dec 18, 2019
@Conduitry
Copy link
Member

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