fix: silence false positive state warning

the continue was essentially a noop because it targeted the wrong for loop
pull/10122/head
Simon Holthausen 1 year ago
parent d171a39b0a
commit dda4ad510f

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: silence false positive state warning

@ -428,7 +428,7 @@ export function analyze_component(root, options) {
for (const scope of [module.scope, instance.scope]) { for (const scope of [module.scope, instance.scope]) {
outer: for (const [name, binding] of scope.declarations) { outer: for (const [name, binding] of scope.declarations) {
if (binding.kind === 'normal' && binding.reassigned) { 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; if (path[0].type !== 'Fragment') continue;
for (let i = 1; i < path.length; i += 1) { for (let i = 1; i < path.length; i += 1) {
const type = path[i].type; const type = path[i].type;
@ -437,7 +437,7 @@ export function analyze_component(root, options) {
type === 'FunctionExpression' || type === 'FunctionExpression' ||
type === 'ArrowFunctionExpression' type === 'ArrowFunctionExpression'
) { ) {
continue; continue inner;
} }
} }

@ -2,9 +2,11 @@
let a = $state(1); let a = $state(1);
let b = 2; let b = 2;
let c = 3; let c = 3;
let d = 4;
</script> </script>
<button onclick={() => a += 1}>a += 1</button> <button onclick={() => a += 1}>a += 1</button>
<button onclick={() => b += 1}>b += 1</button> <button onclick={() => b += 1}>b += 1</button>
<button onclick={() => c += 1}>c += 1</button> <button onclick={() => c += 1}>c += 1</button>
<button onclick={() => d += 1}>d += 1</button>
<p>{a} + {b} + {c} = {a + b + c}</p> <p>{a} + {b} + {c} = {a + b + c}</p>

Loading…
Cancel
Save