diff --git a/.changeset/short-buses-camp.md b/.changeset/short-buses-camp.md new file mode 100644 index 0000000000..b7c0976bc8 --- /dev/null +++ b/.changeset/short-buses-camp.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: silence false positive state warning diff --git a/packages/svelte/src/compiler/phases/2-analyze/index.js b/packages/svelte/src/compiler/phases/2-analyze/index.js index 781ccdfc60..3a4e323a77 100644 --- a/packages/svelte/src/compiler/phases/2-analyze/index.js +++ b/packages/svelte/src/compiler/phases/2-analyze/index.js @@ -428,7 +428,7 @@ export function analyze_component(root, options) { for (const scope of [module.scope, instance.scope]) { outer: for (const [name, binding] of scope.declarations) { if (binding.kind === 'normal' && binding.reassigned) { - for (const { path } of binding.references) { + inner: for (const { path } of binding.references) { if (path[0].type !== 'Fragment') continue; for (let i = 1; i < path.length; i += 1) { const type = path[i].type; @@ -437,7 +437,7 @@ export function analyze_component(root, options) { type === 'FunctionExpression' || type === 'ArrowFunctionExpression' ) { - continue; + continue inner; } } diff --git a/packages/svelte/tests/validator/samples/runes-referenced-nonstate/input.svelte b/packages/svelte/tests/validator/samples/runes-referenced-nonstate/input.svelte index fd9d6c3173..c3a2b38fa7 100644 --- a/packages/svelte/tests/validator/samples/runes-referenced-nonstate/input.svelte +++ b/packages/svelte/tests/validator/samples/runes-referenced-nonstate/input.svelte @@ -2,9 +2,11 @@ let a = $state(1); let b = 2; let c = 3; + let d = 4; +
{a} + {b} + {c} = {a + b + c}