frontend: provide contextual source repair advice
This commit is contained in:
1 parent
008867fe48
commit
2c6c7a3dcd
37 files changed
+562
-24
No files matched your search
@@ -45,7 +45,7 @@ Example:
|
||||
|
||||
## 3. Repair candidates
|
||||
|
||||
The compiler may emit structured suggestions:
|
||||
The compiler MAY emit structured suggestions. The following kinds are illustrative:
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -58,6 +58,10 @@ The compiler may emit structured suggestions:
|
||||
|
||||
Suggestions never modify semantics automatically.
|
||||
|
||||
Each `repair_candidates` element MUST have string `kind`; it MAY additionally have string `hint` and a nonempty ordered array of strings `alternatives`. Serialization order MUST be `kind`, then `hint`, then `alternatives`; absent optional members MUST be omitted. Existing kind-only objects remain valid. Alternatives are spellings for the construct/unit registered for that kind, not byte edits or a claim that the repaired program verifies. Their order MUST be deterministic and implies no preference. In particular, choosing a checked versus wrapping cast remains the agent's semantic decision. Agents MUST select advice by `kind`, not by parsing `hint` or `message`.
|
||||
|
||||
Source advice kinds, fixed hints, applicability and alternative units are registered in `reference/error-codes.md`. An E7001/E7005 diagnostic MUST NOT carry more than one registered source advice candidate; when a registered trigger applies, it MUST carry exactly that candidate. Advice MUST come from the rejecting parser/type rule, MUST NOT change accepted syntax or inference, and MUST preserve the existing code, location, payload and message. Imported source and formatter syntax failures MUST carry the same applicable advice; E7900 replacement MUST discard it.
|
||||
|
||||
## 4. ajid
|
||||
|
||||
`ajid` is the long-running machine interface.
|
||||
|
||||
@@ -391,6 +391,8 @@ 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.
|
||||
|
||||
| Problem | Code |
|
||||
|---|---|
|
||||
| found by the verifier on the lowered AIR | the AIR code; the diagnostic's `file`, `line` and `col` are the source location of the construct the instruction came from, and `air_line`/`air_col` locate it in the lowered AIR (`aji lower`); the verifier's own fields (`function`, `block`, `inst`) are kept |
|
||||
|
||||
Reference in new issue
Block a user