diagnostic codes / Warnings
E0603 shadowing
A new binding hides one that is already in scope.
E0603shadowingname shadows an existing binding in scope; rename
| severity | warn |
|---|---|
| band | Warnings |
| in the v0 bootstrap | emitted |
| explain | ralt explain E0603 |
Shadowing is legal and checked: the inner binding wins for the rest of its block, and the outer one comes back at the closing brace. The warning exists because the two names being identical is usually a typo, not an intent.
What it looks like
e0603.tp
use tier core; fn main() -> i32 { let x = 1; let x = 2; print_i32(x); return 0; }
ralt check e0603.tp e0603.tp:5:5: warn: 'x' shadows an existing binding [E0603 shadowing] name shadows an existing binding in scope; rename echo $? 0
The exit status is 0: a warning does not fail a build. The JSON form of the same diagnostic carries a longer hint than `ralt explain` does — `rename the inner binding or drop shadowing intent` — because the two tables were written at different times.
What to do
- Rename the inner binding.
- If the shadowing is intentional, the build still succeeds; there is no error to silence.
Why the code exists
Shadowing is useful for a value that is transformed once (a parsed form of a raw form). It is also how a typo hides. A warning is the compromise: visible in output, never blocking.
What ralt explain says
ralt explain E0603 E0603 severity: warn name: shadowing hint: name shadows an existing binding in scope; rename
Related
- Statements /docs/reference/statements