fix: allow for duplicate `var` declarations (#15382)

pull/15384/head
Paolo Ricciuti 6 months ago committed by GitHub
parent bbeeed421b
commit c2ec0d9ac2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: allow for duplicate `var` declarations

@ -161,8 +161,12 @@ export class Scope {
}
if (this.declarations.has(node.name)) {
// This also errors on var/function types, but that's arguably a good thing
e.declaration_duplicate(node, node.name);
const binding = this.declarations.get(node.name);
if (binding && binding.declaration_kind !== 'var' && declaration_kind !== 'var') {
// This also errors on function types, but that's arguably a good thing
// declaring function twice is also caught by acorn in the parse phase
e.declaration_duplicate(node, node.name);
}
}
const binding = new Binding(this, node, kind, declaration_kind, initial);

@ -0,0 +1,6 @@
<script>
var test = "";
var test = 42;
</script>
{test}
Loading…
Cancel
Save