Describe the bug
Snippets at the top level declare a variable in the component, if the variable is referenced in a script function, the compiler should make sure it does not lose the reference by moving the function around. Currently this can happen.
Use cases include e.g. passing a snippet to a modal showing function.
Reproduction
<script>
function log() {
console.log(snippet)
}
</script>
{#snippet snippet()}Hello{/snippet}
<button on:click={log}>
log snippet
</button>
REPL
Logs
No response
System Info
Severity
annoyance