Skip to content

Commit

Permalink
fix: silence false positive state warning
Browse files Browse the repository at this point in the history
the continue was essentially a noop because it targeted the wrong for loop
  • Loading branch information
dummdidumm committed Jan 9, 2024
1 parent d171a39 commit dda4ad5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/short-buses-camp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: silence false positive state warning
4 changes: 2 additions & 2 deletions packages/svelte/src/compiler/phases/2-analyze/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -437,7 +437,7 @@ export function analyze_component(root, options) {
type === 'FunctionExpression' ||
type === 'ArrowFunctionExpression'
) {
continue;
continue inner;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
let a = $state(1);
let b = 2;
let c = 3;
let d = 4;
</script>

<button onclick={() => a += 1}>a += 1</button>
<button onclick={() => b += 1}>b += 1</button>
<button onclick={() => c += 1}>c += 1</button>
<button onclick={() => d += 1}>d += 1</button>
<p>{a} + {b} + {c} = {a + b + c}</p>

1 comment on commit dda4ad5

@vercel
Copy link

@vercel vercel bot commented on dda4ad5 Jan 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

svelte-5-preview – ./sites/svelte-5-preview

svelte-octane.vercel.app
svelte-5-preview.vercel.app
svelte-5-preview-git-main-svelte.vercel.app
svelte-5-preview-svelte.vercel.app

Please sign in to comment.