Skip to content

Commit df03af2

Browse files
authored
fix: emit right error for a shadowed invalid rune (#15892)
Co-authored-by: 7nik <[email protected]>
1 parent 1cab761 commit df03af2

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

.changeset/tall-cherries-fix.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: emit right error for a shadowed invalid rune

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export function Identifier(node, context) {
3939
if (
4040
is_rune(node.name) &&
4141
context.state.scope.get(node.name) === null &&
42-
context.state.scope.get(node.name.slice(1)) === null
42+
context.state.scope.get(node.name.slice(1))?.kind !== 'store_sub'
4343
) {
4444
/** @type {Expression} */
4545
let current = node;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { test } from '../../test';
2+
3+
export default test({
4+
error: {
5+
code: 'rune_invalid_name',
6+
message: '`$state.foo` is not a valid rune'
7+
}
8+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class State {
2+
value = $state.foo();
3+
}
4+
5+
export const state = new State();

0 commit comments

Comments
 (0)