Skip to content

ReferenceError while having #each inside a snippet #15531

@MartinMikusat

Description

@MartinMikusat

Describe the bug

While using #each inside a snippet, trying to pass the snippet as an argument to a function defined inside the component definition throws a "ReferenceError: x is not defined"

Passing it to a function defined inside an onclick handler of a button element still works

Removing the #each loop fixes the issue

Reproduction

https://svelte.dev/playground/646d5eeee3be4efca6f6a01dd89caf9d?version=5.23.0

Logs

System Info

System:
    OS: macOS 15.3.2
    CPU: (8) arm64 Apple M1
    Memory: 186.53 MB / 8.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.13.1 - /usr/local/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 11.1.0 - /usr/local/bin/npm
    pnpm: 6.32.1 - /usr/local/bin/pnpm
    bun: 1.2.5 - ~/.bun/bin/bun
  Browsers:
    Chrome: 134.0.6998.89
    Safari: 18.3.1
  npmPackages:
    svelte: ^5.23.0 => 5.23.0

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