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

fix: improve consttag ordering in non-runes mode #11908

Merged
merged 23 commits into from
Jun 6, 2024
Merged

Conversation

trueadm
Copy link
Contributor

@trueadm trueadm commented Jun 4, 2024

Fixes #11450

Copy link

changeset-bot bot commented Jun 4, 2024

🦋 Changeset detected

Latest commit: f4491cd

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
svelte Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Rich-Harris
Copy link
Member

Got the cyclical dependency detection working, but in the process uncovered a bug that's been lying dormant for a very long time. It turns out that when we call create_block (both the client and server implementations of it), we skip over the universal visitor that updates context.state.scope with the fragment's scope. Because of that, while this works...

{#if true}
  {@const a = b}
  {@const b = 42}
  <h1>{a}</h1>
{/if}

..this (for example) does not:

<Child>
  {@const a = b}
  {@const b = 42}
  <h1>{a}</h1>
</Child>

Ideally we would only call create_block inside the Fragment visitors (perhaps we move the create_block logic inside the visitor?) but as things stand that doesn't quite work. Looking into it

@Rich-Harris
Copy link
Member

This turned into a bit of a rabbit hole but I'm glad to have uncovered that bug as I've no doubt it would have blown up in our faces at some point. Have removed create_block from the server code, but still need to do something similar for client code

@dummdidumm dummdidumm merged commit 9f823b9 into main Jun 6, 2024
8 checks passed
@dummdidumm dummdidumm deleted the fix-const-tag-order branch June 6, 2024 08:39
@Rich-Harris Rich-Harris mentioned this pull request Jun 6, 2024
5 tasks
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 this pull request may close these issues.

Svelte5 : melt-ui preprocessor caused {@const} values to be used before initialization.
3 participants