Skip to content

Language Server: False "Cannot find name" error in nested snippet renders #2664

@scirexs

Description

@scirexs

Describe the bug

The language server incorrectly reports "Cannot find name" error when using {@render ...} inside snippet definitions, even though the snippet function is properly defined under specific conditions.

Reproduction

<script module lang="ts">
</script>

<script lang="ts">
  function foo() { console.log("hello") }
</script>

{#snippet test()}
  {@render renderButton()}
{/snippet}

{#snippet renderButton()}
  <button type="button" onclick={foo}>test button</button>
{/snippet}

Image

Expected behaviour

No "Cannot find name" error should be reported for properly defined snippet functions.

Image

System Info

  • OS: Windows 11
  • IDE: VSCode (Ver. 1.96.3)
  • Svelte for VS Code: 109.5.2

Which package is the issue about?

svelte-language-server

Additional Information, eg. Screenshots

I have verified this issue across multiple versions:

  • The error is present in versions 109.5.2 and 109.5.0
  • The error does not exist in version 109.4.0. The Expected behaviour screenshot was taken using this version.

The error can be eliminated by either:

  • Removing the onclick={foo} handler
  • Removing the <script module lang="ts"></script> tag

Additionally, {@render renderButton()} functions correctly when used outside of snippet definitions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy