Skip to content

Each blocks after slot with let directive captures wrong ctx #3966

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
RedHatter opened this issue Nov 21, 2019 · 1 comment · Fixed by #3997
Closed

Each blocks after slot with let directive captures wrong ctx #3966

RedHatter opened this issue Nov 21, 2019 · 1 comment · Fixed by #3997
Labels

Comments

@RedHatter
Copy link
Contributor

Describe the bug
When an each block follows a slot that uses a let directive that hides a variable of the same name in the parent then the each block incorrectly references the value from inside the slot.

To Reproduce
https://svelte.dev/repl/537557d31921471e97632c6780c0ea39?version=3.15.0

The first line a a shows that the initial value of the array is ['a'].
The second line b shows that the value of the array inside the slot is ['b'].
The last line a b is unexpected. It shows that the value of the array is still ['a'] yet the each block is referencing the array from the slot, ['b'].

Expected behavior
I would expect either the each block to use the parents value or for the svelte compiler to warn about let directive variable already being defined.

@Conduitry
Copy link
Member

It looks like this was fixed on master, presumably by #3945 (the third line is now 'a a'), but it would still be good to have a test for this.

@Conduitry Conduitry added the bug label Nov 24, 2019
Conduitry added a commit to Conduitry/sveltejs_svelte that referenced this issue Nov 26, 2019
Conduitry added a commit that referenced this issue Nov 26, 2019
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.

2 participants