Migrate local const and static parser failures to structured diagnostics
- Dominant language
- Rust
- Stars
- 53
- Forks
- 16
- Avg merge
- 4h 22m
- Merged PRs (30d)
- 46
Description
Tracked by #346.
## Why
Local `const` and `static` declarations are intentionally rejected, but `front/parser/src/parser/stmt.rs` and the for-loop initializer path still print ad-hoc text and return `None`. That loses the stable diagnostic contract used by the rest of the compiler.
## Scope
- Replace only the local `const` and `static` failure paths with `ParseError`/structured diagnostic data.
- Cover ordinary blocks and `for` initializers.
- Point at the qualifier token.
- Explain that both forms are top-level only and suggest `var` for local storage where appropriate.
- Do not change storage-class semantics.
## Completion criteria
- [ ] No direct `println!` is used for these failures.
- [ ] Human diagnostics include context and a useful help message.
- [ ] JSON error output remains valid.
- [ ] Positive top-level `const` and `static` cases remain accepted.
- [ ] Parser or CLI regression tests cover all changed paths.
Contributor guide
Research direction
Start in front/parser/src/parser/stmt.rs and trace the for-loop initializer path where local const and static declarations fail. Replace only those ad-hoc diagnostic paths with structured ParseError data, pointing at the qualifier and preserving top-level acceptance and storage semantics. Add parser or CLI regression coverage for ordinary blocks, for initializers, human and JSON diagnostics, and positive top-level cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 74/100