mirror of
https://github.com/imjasonh/nescript
synced 2026-07-11 02:02:58 +00:00
Analyzer: E0502 on assignment to undefined variable
Previously an assignment to an undeclared name was silently accepted because the IR lowering would synthesize a fresh VarId for it. Now the analyzer emits E0502 with the same "did you mean" suggestion path as read-side undefined variable errors. https://claude.ai/code/session_01W6eQFStA66EuMKHUFo2rx3
This commit is contained in:
parent
1778ae0ec8
commit
59970a4a45
2 changed files with 24 additions and 0 deletions
|
|
@ -797,6 +797,11 @@ impl Analyzer {
|
|||
*span,
|
||||
));
|
||||
}
|
||||
} else {
|
||||
// Assigning to an undeclared name is an
|
||||
// error — the lowering would otherwise
|
||||
// silently synthesize a VarId for it.
|
||||
self.emit_undefined_var(name, *span);
|
||||
}
|
||||
}
|
||||
LValue::ArrayIndex(name, idx) => {
|
||||
|
|
@ -808,6 +813,8 @@ impl Analyzer {
|
|||
*span,
|
||||
));
|
||||
}
|
||||
} else {
|
||||
self.emit_undefined_var(name, *span);
|
||||
}
|
||||
// Indexing an array counts as a read of the array,
|
||||
// and the index expression itself may contain reads.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue