Skip to content

Svelte 5: error if there are two spaces after @const #9711

@ota-meshi

Description

@ota-meshi

Describe the bug

When defining {@const} using Svelte v5 preview, two spaces after the @const keyword will result in an error. There is no problem if there is only one space. There is also no problem with Svelte v4.

Reproduction

e.g.

<script>
    let list = [1, 2, 3];
</script>

{#each list as e}
    {@const  a = e * 2}
    {e} * 2 = {a}<br>
{/each}

https://svelte-5-preview.vercel.app/#H4sIAAAAAAAAEz2OTQrCMBCFrzKMOwkU665G0XO0XcR0ioE0DUkqSMjdnVB0du97P0zG2ViK2PUZnVoIO3x4jwLTx1cR32QTsY7rFnQlMupgfLoNDvgsJbAmJrhCfxLQCjiPl8HJ5p8aXD6Q0q89piJQ2av5rlfHCBSXCY7Q_gwqVTHNqshn4JHc1An2-ZNlncxsaMIuhY3KWL7fRWigxAAAAA==

Logs

Error compiling App.svelte
{@const ...} must be an assignment
line 6 column 4

System Info

System:
    OS: macOS 13.2.1
    CPU: (8) x64 Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
    Memory: 83.73 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.18.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 9.8.1 - /usr/local/bin/npm
    pnpm: 8.5.0 - /usr/local/bin/pnpm
  Browsers:
    Chrome: 119.0.6045.199
    Safari: 16.3
  npmPackages:
    svelte: ^5.0.0-next.15 => 5.0.0-next.15

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