Skip to content

Unexpected #each block behavior with destructuring #17227

@x0k

Description

@x0k

Describe the bug

Using the construct {#each gen() as [item]} with a generator that mutates the yielded object produces a result that differs from the behavior of a for…of loop with destructuring.

If this behavior is expected, it should be documented.

Reproduction

REPL

Logs

System Info

System:
    OS: Linux 6.12 cpe:/o:nixos:nixos:25.05 25.05 (Warbler)
    CPU: (12) x64 Intel(R) Core(TM) i5-10400F CPU @ 2.90GHz
    Memory: 4.58 GB / 15.56 GB
    Container: Yes
    Shell: 5.2.37 - /run/current-system/sw/bin/bash
  Binaries:
    Node: 24.7.0 - /nix/store/ffx0ixqnd6arwnjqmjv844krhay4iycj-nodejs-24.7.0/bin/node
    npm: 11.5.1 - /nix/store/ffx0ixqnd6arwnjqmjv844krhay4iycj-nodejs-24.7.0/bin/npm
    pnpm: 10.15.1 - /nix/store/dmnyvw4gf3i8b65s3k7q4ws3257m6zrs-pnpm-10.15.1/bin/pnpm
  Browsers:
    Brave Browser: 142.1.84.141
  npmPackages:
    svelte: ^5.30.0 => 5.43.14

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions