Skip to content

fix: only use iterator destructuring logic if there's an array pattern #16000

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
wants to merge 1 commit into from

Conversation

paoloricciuti
Copy link
Member

Closes #15996

The logic introduced in #15813 produce much more chunky code...while this is not really a problem since the generated code should gzip wonderfully we really don't need to use that logic unless there's an ArrayPattern in the declarator.

I've added a snapshot test but I'm not sure is worth having but i can remove it easily if we think it's not worth.

Also this is walking the ObjectPattern because if at any point in the destructure there's an array we need to fall back to what @Ocean-OS introduced for the same reason.

Before submitting the PR, please make sure you do the following

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • Prefix your PR title with feat:, fix:, chore:, or docs:.
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.
  • If this PR changes code within packages/svelte/src, add a changeset (npx changeset).

Tests and linting

  • Run the tests with pnpm test and lint the project with pnpm lint

Copy link

changeset-bot bot commented May 25, 2025

🦋 Changeset detected

Latest commit: 8d0114b

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

@svelte-docs-bot
Copy link

Copy link
Contributor

Playground

pnpm add https://pkg.pr.new/svelte@16000

@Rich-Harris
Copy link
Member

I think we need to revisit #15813 anyway, because in a case like this it's still broken (albeit differently/less so than before)

@paoloricciuti
Copy link
Member Author

I think we need to revisit #15813 anyway, because in a case like this it's still broken (albeit differently/less so than before)

Mmm tbf i don't think it's even possible to have an universal way to deal with iterators because you can do all sort of funky behaviours in them and it boils down to them not being pure.

@Rich-Harris
Copy link
Member

Closing in favour of #16015

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.

Destructuring $derived results in quadratic code size
2 participants