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

Cannot find variable xxx in if block #7250

Closed
blaumeise20 opened this issue Feb 11, 2022 · 1 comment
Closed

Cannot find variable xxx in if block #7250

blaumeise20 opened this issue Feb 11, 2022 · 1 comment

Comments

@blaumeise20
Copy link
Contributor

Describe the bug

This is related to #7241

When running this code:

<script>
	import Component2 from "./Component2.svelte";
	let val = { foo: "bar", baz: 2 };
</script>

<Component2>
	{@const hi = val.foo}
	{#if val.baz > 1}
		hello {hi}
	{/if}
</Component2>

there is a runtime exception cannot find variable hi, but there are no compilation errors.
To try you have to create an empty file Component2.svelte in the REPL and paste <slot /> into it. Sorry but I didn't manage to save it.

Reproduction

To try you have to create an empty file Component2.svelte in the REPL and paste <slot /> into it. Sorry but I didn't manage to save it.

Logs

Can't find variable: hi

System Info

System:
    OS: macOS 11.6
    CPU: (8) x64 Apple M1
    Memory: 41.08 MB / 8.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 16.3.0 - /usr/local/bin/node
    npm: 7.15.1 - /usr/local/bin/npm
  Browsers:
    Chrome: 98.0.4758.80
    Safari: 14.1.2
  npmPackages:
    svelte: ^3.46.4 => 3.46.4 
    webpack: ^5.68.0 => 5.68.0 

Bug also happens in browser REPL

Severity

annoyance

@baseballyama
Copy link
Member

Duplicate of #7189

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

No branches or pull requests

3 participants