fix: emit right error for a shadowed invalid rune (#15892)

Co-authored-by: 7nik <kifiranet@gmail.com>
pull/15900/head
7nik 4 months ago committed by GitHub
parent 1cab761110
commit df03af2e9d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: emit right error for a shadowed invalid rune

@ -39,7 +39,7 @@ export function Identifier(node, context) {
if ( if (
is_rune(node.name) && is_rune(node.name) &&
context.state.scope.get(node.name) === null && context.state.scope.get(node.name) === null &&
context.state.scope.get(node.name.slice(1)) === null context.state.scope.get(node.name.slice(1))?.kind !== 'store_sub'
) { ) {
/** @type {Expression} */ /** @type {Expression} */
let current = node; let current = node;

@ -0,0 +1,8 @@
import { test } from '../../test';
export default test({
error: {
code: 'rune_invalid_name',
message: '`$state.foo` is not a valid rune'
}
});

@ -0,0 +1,5 @@
class State {
value = $state.foo();
}
export const state = new State();
Loading…
Cancel
Save