Skip to content

Commit dda4ad5

Browse files
committed
fix: silence false positive state warning
the continue was essentially a noop because it targeted the wrong for loop
1 parent d171a39 commit dda4ad5

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

.changeset/short-buses-camp.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: silence false positive state warning

packages/svelte/src/compiler/phases/2-analyze/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ export function analyze_component(root, options) {
428428
for (const scope of [module.scope, instance.scope]) {
429429
outer: for (const [name, binding] of scope.declarations) {
430430
if (binding.kind === 'normal' && binding.reassigned) {
431-
for (const { path } of binding.references) {
431+
inner: for (const { path } of binding.references) {
432432
if (path[0].type !== 'Fragment') continue;
433433
for (let i = 1; i < path.length; i += 1) {
434434
const type = path[i].type;
@@ -437,7 +437,7 @@ export function analyze_component(root, options) {
437437
type === 'FunctionExpression' ||
438438
type === 'ArrowFunctionExpression'
439439
) {
440-
continue;
440+
continue inner;
441441
}
442442
}
443443

packages/svelte/tests/validator/samples/runes-referenced-nonstate/input.svelte

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
let a = $state(1);
33
let b = 2;
44
let c = 3;
5+
let d = 4;
56
</script>
67

78
<button onclick={() => a += 1}>a += 1</button>
89
<button onclick={() => b += 1}>b += 1</button>
910
<button onclick={() => c += 1}>c += 1</button>
11+
<button onclick={() => d += 1}>d += 1</button>
1012
<p>{a} + {b} + {c} = {a + b + c}</p>

0 commit comments

Comments
 (0)