From f6aa8b2de2ce7f90fbff59a5309158d2cfd6f7c5 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Thu, 25 Apr 2024 08:45:51 -0400 Subject: [PATCH] handle store subscriptions --- .../src/compiler/phases/2-analyze/index.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/svelte/src/compiler/phases/2-analyze/index.js b/packages/svelte/src/compiler/phases/2-analyze/index.js index 00cb5a29ba..d7d02f19db 100644 --- a/packages/svelte/src/compiler/phases/2-analyze/index.js +++ b/packages/svelte/src/compiler/phases/2-analyze/index.js @@ -1071,18 +1071,18 @@ function is_safe_identifier(expression, scope) { if (node.type !== 'Identifier') return false; const binding = scope.get(node.name); + if (!binding) return true; - if ( - binding && - (binding.kind === 'prop' || - binding.kind === 'bindable_prop' || - binding.kind === 'rest_prop' || - binding.declaration_kind === 'import') - ) { - return false; + if (binding.kind === 'store_sub') { + return is_safe_identifier({ name: node.name.slice(1), type: 'Identifier' }, scope); } - return true; + return ( + binding.declaration_kind !== 'import' && + binding.kind !== 'prop' && + binding.kind !== 'bindable_prop' && + binding.kind !== 'rest_prop' + ); } /** @type {import('./types').Visitors} */