Skip to content

Commit 930c532

Browse files
committed
fix
1 parent ffc4769 commit 930c532

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

packages/svelte/src/compiler/phases/2-analyze/visitors/Identifier.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ export function Identifier(node, context) {
9191
if (context.state.expression) {
9292
context.state.expression.dependencies.add(binding);
9393
context.state.expression.has_state ||=
94-
!binding.is_function() && !context.state.scope.evaluate(node).is_known;
94+
binding.kind !== 'static' &&
95+
!binding.is_function() &&
96+
!context.state.scope.evaluate(node).is_known;
9597
}
9698

9799
if (

packages/svelte/src/compiler/phases/scope.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1153,7 +1153,7 @@ export function create_scopes(ast, root, allow_reactive_declarations, parent) {
11531153
const is_keyed =
11541154
node.key &&
11551155
(node.key.type !== 'Identifier' || !node.index || node.key.name !== node.index);
1156-
scope.declare(b.id(node.index), is_keyed ? 'template' : 'normal', 'const', node);
1156+
scope.declare(b.id(node.index), is_keyed ? 'template' : 'static', 'const', node);
11571157
}
11581158
if (node.key) visit(node.key, { scope });
11591159

packages/svelte/src/compiler/types/index.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,8 @@ export type BindingKind =
265265
| 'snippet' // A snippet parameter
266266
| 'store_sub' // A $store value
267267
| 'legacy_reactive' // A `$:` declaration
268-
| 'template'; // A binding declared in the template, e.g. in an `await` block or `const` tag
268+
| 'template' // A binding declared in the template, e.g. in an `await` block or `const` tag
269+
| 'static'; // A binding whose value is known to be static (i.e. each index)
269270

270271
export type DeclarationKind =
271272
| 'var'

0 commit comments

Comments
 (0)