Skip to content

Commit 6b01659

Browse files
committed
deconflict generated names against globals - fixes #9559
1 parent b966470 commit 6b01659

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

.changeset/green-hounds-play.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: deconflict generated names against globals

packages/svelte/src/compiler/phases/scope.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,10 @@ export class Scope {
184184
declaration.references.push({ node, path });
185185
} else if (this.#parent) {
186186
this.#parent.reference(node, path);
187+
} else {
188+
// no declaration was found, and this is the top level scope,
189+
// which means this is a global
190+
this.root.conflicts.add(node.name);
187191
}
188192
}
189193
}

0 commit comments

Comments
 (0)