Skip to content

False-positive block-scoped variable redeclaration report #2762

Closed
@shadow-identity

Description

@shadow-identity

Describe the bug

Svelte-check (and vscode extension) incorrectly reports variables defined with @const in different blocks as redeclared. For the following block it reports "Error: Cannot redeclare block-scoped variable 'name'. (js)" twice, tho the Svelte compiler has no issues with compiling or rendering it.
This behavior seems to be incorrect because @const is scoped.

Reproduction

Simple reproduction repository: https://github.com/shadow-identity/block-scoped-repro

{#key "wrld"}
  {@const name = "World"}
  <p>Hello {name}</p>
{/key}

{#key "pvlk"}
  {@const name = "Pavlik"}
  <p>Hello {name}</p>
{/key}

Expected behaviour

Neither svelte-check nor vscode extension should report any error within the code block.

System Info

macos 15.4.1 (24E263)

Which package is the issue about?

svelte-check

Additional Information, eg. Screenshots

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixedFixed in master branch. Pending production release.bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions