Skip to content

Defined function becomes undefined #17393

@ginpei

Description

@ginpei

Describe the bug

I've been migrating my app to Svelte 5 and found a declared function becomes undefined in some cases

I can avoid the issue by declaring it as a variable (const f = () => >..). Also this doesn't occur in the rune mode

Reproduction

https://svelte.dev/playground/32fe25bdf13a4cbe8bdf053d68dfe777?version=5.46.0

<script>
  $: items = [];

  function myFunction(value) {
  }
  console.log(typeof myFunction); // => undefined
</script>

{#each items.filter(myFunction) as item}
  <input bind:value={item.value} />
{/each}

<style>
</style>
Error: undefined is not a function

	in <unknown>
	in __wrapper.svelte

    at Array.filter (<anonymous>)
    at eval (playground:output:5734:31)
    at untrack (playground:output:4402:11)
    at eval (playground:output:5734:6)
    at eval (playground:output:5066:21)
    at update_reaction (playground:output:4010:17)
    at execute_derived (playground:output:2244:13)
    at update_derived (playground:output:2260:15)
    at get (playground:output:4326:5)
    at eval (playground:output:5100:32)

Logs

System Info

System:
    OS: Linux 6.14 Ubuntu 24.04.2 LTS 24.04.2 LTS (Noble Numbat)
    CPU: (4) x64 Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz
    Memory: 9.94 GB / 15.42 GB
    Container: Yes
    Shell: 5.2.21 - /bin/bash
  Binaries:
    Node: 20.19.6 - /home/ubuntu/.nvm/versions/node/v20.19.6/bin/node
    npm: 3.10.10 - /home/ubuntu/***/node_modules/.bin/npm
  npmPackages:
    svelte: ^5.46.0 => 5.46.0

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions