From 5315895bbe426288cf04091e89b1a9a5db256065 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Fri, 21 Feb 2025 15:29:47 -0500 Subject: [PATCH] chore: remove unnecessary `binding.is_called` property --- .changeset/green-geckos-tickle.md | 5 +++++ .../src/compiler/phases/2-analyze/visitors/Attribute.js | 2 +- .../compiler/phases/2-analyze/visitors/CallExpression.js | 8 -------- .../2-analyze/visitors/TaggedTemplateExpression.js | 9 +-------- packages/svelte/src/compiler/phases/scope.js | 1 - 5 files changed, 7 insertions(+), 18 deletions(-) create mode 100644 .changeset/green-geckos-tickle.md diff --git a/.changeset/green-geckos-tickle.md b/.changeset/green-geckos-tickle.md new file mode 100644 index 000000000000..843b3d1bda71 --- /dev/null +++ b/.changeset/green-geckos-tickle.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +chore: remove unnecessary `binding.is_called` property diff --git a/packages/svelte/src/compiler/phases/2-analyze/visitors/Attribute.js b/packages/svelte/src/compiler/phases/2-analyze/visitors/Attribute.js index 42e449896928..561a00452684 100644 --- a/packages/svelte/src/compiler/phases/2-analyze/visitors/Attribute.js +++ b/packages/svelte/src/compiler/phases/2-analyze/visitors/Attribute.js @@ -162,7 +162,7 @@ function get_delegated_event(event_name, handler, context) { return unhoisted; } - if (binding !== null && binding.initial !== null && !binding.updated && !binding.is_called) { + if (binding !== null && binding.initial !== null && !binding.updated) { const binding_type = binding.initial.type; if ( diff --git a/packages/svelte/src/compiler/phases/2-analyze/visitors/CallExpression.js b/packages/svelte/src/compiler/phases/2-analyze/visitors/CallExpression.js index ce520cc98055..4d09d9293fb2 100644 --- a/packages/svelte/src/compiler/phases/2-analyze/visitors/CallExpression.js +++ b/packages/svelte/src/compiler/phases/2-analyze/visitors/CallExpression.js @@ -213,14 +213,6 @@ export function CallExpression(node, context) { break; } - if (node.callee.type === 'Identifier') { - const binding = context.state.scope.get(node.callee.name); - - if (binding !== null) { - binding.is_called = true; - } - } - // `$inspect(foo)` or `$derived(foo) should not trigger the `static-state-reference` warning if (rune === '$inspect' || rune === '$derived') { context.next({ ...context.state, function_depth: context.state.function_depth + 1 }); diff --git a/packages/svelte/src/compiler/phases/2-analyze/visitors/TaggedTemplateExpression.js b/packages/svelte/src/compiler/phases/2-analyze/visitors/TaggedTemplateExpression.js index eacb8a342ac2..881ee5a85edd 100644 --- a/packages/svelte/src/compiler/phases/2-analyze/visitors/TaggedTemplateExpression.js +++ b/packages/svelte/src/compiler/phases/2-analyze/visitors/TaggedTemplateExpression.js @@ -1,4 +1,4 @@ -/** @import { TaggedTemplateExpression, VariableDeclarator } from 'estree' */ +/** @import { TaggedTemplateExpression } from 'estree' */ /** @import { Context } from '../types' */ import { is_pure } from './shared/utils.js'; @@ -12,12 +12,5 @@ export function TaggedTemplateExpression(node, context) { context.state.expression.has_state = true; } - if (node.tag.type === 'Identifier') { - const binding = context.state.scope.get(node.tag.name); - - if (binding !== null) { - binding.is_called = true; - } - } context.next(); } diff --git a/packages/svelte/src/compiler/phases/scope.js b/packages/svelte/src/compiler/phases/scope.js index 41e1c78c057b..64ba10a989e9 100644 --- a/packages/svelte/src/compiler/phases/scope.js +++ b/packages/svelte/src/compiler/phases/scope.js @@ -57,7 +57,6 @@ export class Binding { */ metadata = null; - is_called = false; mutated = false; reassigned = false; updated = false;