diff --git a/packages/svelte/src/compiler/phases/2-analyze/index.js b/packages/svelte/src/compiler/phases/2-analyze/index.js index 2920a9261059..68f3ac599ffb 100644 --- a/packages/svelte/src/compiler/phases/2-analyze/index.js +++ b/packages/svelte/src/compiler/phases/2-analyze/index.js @@ -5,7 +5,6 @@ import * as assert from '../../utils/assert.js'; import { extract_identifiers, extract_paths, - get_callee_name, is_event_attribute, is_text_attribute, object @@ -268,11 +267,7 @@ export function analyze_component(root, options) { !Runes.includes(name) || (declaration !== null && // const state = $state(0) is valid - !Runes.includes( - /** @type {string} */ ( - get_callee_name(/** @type {import('estree').Expression} */ (declaration.initial)) - ) - ) && + get_rune(declaration.initial, instance.scope) === null && // allow `import { derived } from 'svelte/store'` in the same file as `const x = $derived(..)` because one is not a subscription to the other !( name === '$derived' && diff --git a/packages/svelte/src/compiler/phases/scope.js b/packages/svelte/src/compiler/phases/scope.js index 302e182c95bf..95c192d4d404 100644 --- a/packages/svelte/src/compiler/phases/scope.js +++ b/packages/svelte/src/compiler/phases/scope.js @@ -3,11 +3,7 @@ import { walk } from 'zimmerframe'; import { is_element_node } from './nodes.js'; import * as b from '../utils/builders.js'; import { error } from '../errors.js'; -import { - extract_identifiers, - extract_identifiers_from_expression, - get_callee_name -} from '../utils/ast.js'; +import { extract_identifiers, extract_identifiers_from_expression } from '../utils/ast.js'; import { Runes } from './constants.js'; export class Scope { diff --git a/packages/svelte/src/compiler/utils/ast.js b/packages/svelte/src/compiler/utils/ast.js index 416c223584e2..cf8b859bfc66 100644 --- a/packages/svelte/src/compiler/utils/ast.js +++ b/packages/svelte/src/compiler/utils/ast.js @@ -20,19 +20,6 @@ export function object(expression) { return expression; } -/** - * Returns the name of callee if the given expression is a call expression. - * @param {import('estree').Expression | null | undefined} node - */ -export function get_callee_name(node) { - if (!node) return null; - if (node.type !== 'CallExpression') return null; - if (node.callee.type !== 'Identifier' && node.callee.type !== 'MemberExpression') return null; - - const id = object(node.callee); - return id === null ? null : id.name; -} - /** * Returns true if the attribute contains a single static text node. * @param {import('#compiler').Attribute} attribute