frontend: collect independent source diagnostics without cascades
This commit is contained in:
1 parent
2c6c7a3dcd
commit
4cda44823d
47 files changed
+697
-44
No files matched your search
@@ -43,6 +43,8 @@ Example:
|
||||
}
|
||||
```
|
||||
|
||||
A rejected source module MAY produce multiple diagnostic JSON lines under spec 15 §10. Each line retains the same envelope; consumers MUST read the complete diagnostic stream rather than treating stdout as one JSON object.
|
||||
|
||||
## 3. Repair candidates
|
||||
|
||||
The compiler MAY emit structured suggestions. The following kinds are illustrative:
|
||||
|
||||
@@ -391,7 +391,13 @@ A byte string or array used where a `slice<u8>` is expected is materialized in f
|
||||
|
||||
## 10. Diagnostics
|
||||
|
||||
Recognized rejected spellings MUST carry the applicable source advice candidate registered in `reference/error-codes.md`, using spec 10 §3. These candidates describe existing syntax; they MUST NOT accept aliases, infer a missing `var` annotation, invent a slice end, duplicate a receiver expression or select a cast mode. `let` inference remains unchanged. Parser recovery and diagnostic collection are unaffected by this advice requirement.
|
||||
Recognized rejected spellings MUST carry the applicable source advice candidate registered in `reference/error-codes.md`, using spec 10 §3. These candidates describe existing syntax; they MUST NOT accept aliases, infer a missing `var` annotation, invent a slice end, duplicate a receiver expression or select a cast mode. `let` inference remains unchanged.
|
||||
|
||||
**Independent source errors.** A rejected source compilation MUST expose at most 32 frontend diagnostics, in parser declaration order or concrete lowering order. Each failed top-level declaration/body contributes at most its first error. Module/import headers, linking failures, generic specialization, types, signatures and module requirements remain first-error phase stops. A syntax-error module MUST NOT reach linking/lowering; a module with body errors MUST NOT emit AIR or reach the verifier. No recovery placeholder may escape. Existing diagnostic fields and the first diagnostic MUST be preserved; later independent failures MAY add JSON lines. Check/lower/run/report/explore MUST expose the same list, including advice; fmt MUST expose the same syntax list and refuse formatting it.
|
||||
|
||||
Parser recovery MUST occur only after an independently bounded `fn`, `struct` or `enum` item: matching `()`, `[]` and `{}` tokens identify a complete outer body, the failure is within that item, and the next token is EOF or another declaration keyword. An unbalanced/mismatched delimiter, missing body, top-level junk or invalid lexical token other than the recognized lone `!` MUST stop recovery. A new function declaration before the first outer body MUST NOT supply the failed declaration's missing body; static `fn` selections/contracts are not declaration boundaries. Header/import failures stop before items. Parsing the next item MUST reset transient expression/advice state. Source import traversal retains its existing deterministic order: the first failing imported module exposes its own recovered list and then stops linking; a std syntax failure remains one E7900 without advice.
|
||||
|
||||
Body collection MUST begin only after complete declaration/signature/requirement validation. Bodies read other functions through those validated declarations, not through body outputs; a failed callee MUST NOT manufacture a caller error. Every body MUST start with fresh function state, and failure MUST discard its output and restore module accumulations before continuing. Later instantiations of a failed generic source declaration MUST be skipped, preserving one error per source function. Existing one-per-code/source-location deduplication remains mandatory. An unimplemented body encountered before any collected error retains the unimplemented result; after an error it is skipped and collection continues. At the fixed limit collection stops and the module remains rejected.
|
||||
|
||||
| Problem | Code |
|
||||
|---|---|
|
||||
|
||||
Reference in new issue
Block a user