more correct error code - it's the state that isn't mutated, not the rune

pull/9668/head
Rich Harris 3 years ago
parent 57e1c08af2
commit f01a15fd05

@ -218,7 +218,7 @@ export function analyze_module(ast, options) {
for (const [, scope] of scopes) { for (const [, scope] of scopes) {
for (const [name, binding] of scope.declarations) { for (const [name, binding] of scope.declarations) {
if (binding.kind === 'state' && !binding.mutated) { if (binding.kind === 'state' && !binding.mutated) {
warn(warnings, binding.node, [], 'state-rune-not-mutated', name); warn(warnings, binding.node, [], 'state-not-mutated', name);
} }
} }
} }
@ -377,7 +377,7 @@ export function analyze_component(root, options) {
for (const [, scope] of instance.scopes) { for (const [, scope] of instance.scopes) {
for (const [name, binding] of scope.declarations) { for (const [name, binding] of scope.declarations) {
if (binding.kind === 'state' && !binding.mutated) { if (binding.kind === 'state' && !binding.mutated) {
warn(warnings, binding.node, [], 'state-rune-not-mutated', name); warn(warnings, binding.node, [], 'state-not-mutated', name);
} }
} }
} }

@ -22,7 +22,7 @@ const runes = {
`It looks like you're using the $${name} rune, but there is a local binding called ${name}. ` + `It looks like you're using the $${name} rune, but there is a local binding called ${name}. ` +
`Referencing a local variable with a $ prefix will create a store subscription. Please rename ${name} to avoid the ambiguity.`, `Referencing a local variable with a $ prefix will create a store subscription. Please rename ${name} to avoid the ambiguity.`,
/** @param {string} name */ /** @param {string} name */
'state-rune-not-mutated': (name) => 'state-not-mutated': (name) =>
`${name} is declared with $state(...) but is never updated. Did you mean to create a function that changes its value?`, `${name} is declared with $state(...) but is never updated. Did you mean to create a function that changes its value?`,
/** @param {string} name */ /** @param {string} name */
'non-state-reference': (name) => 'non-state-reference': (name) =>

Loading…
Cancel
Save