Skip to content

Crash when using arrow functions in {@const} #7134

Closed
@TheOnlyTails

Description

@TheOnlyTails

Describe the bug

When creating a markup variable with {@const}, whose value uses an arrow function in some way (for example, finding an item in an array), Svelte will fail with the error:

func is not defined

Reproduction

https://svelte.dev/repl/77bcccb636f64213ab20c666a870ed96

Logs

Uncaught (in promise) ReferenceError: func is not defined
    at get_each_context_3 (FeatureShowcase.svelte:210:34)
    at Array.create_if_block_13 (FeatureShowcase.svelte:209:11)
    at Object.update [as p] (FeatureShowcase.svelte:242:24)
    at update (index.mjs:1085:36)
    at flush (index.mjs:1052:13)

System Info

the command failed, but here's my system info:
- OS: Latest Windows 11 Insider build (22533.1001) in the Dev channel
- node v17.3.0
- npm v7.20.6
- Browser - Microsoft Edge 97.0.1072.55 (latest)
- Svelte 3.46.1
- SvelteKit 1.0.0-next.229

Severity

blocking an upgrade

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcompilerChanges relating to the compiler

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions