frontend: provide contextual source repair advice

This commit is contained in:
dev committed 2026-10-09 14:04:40 +03:00
1 parent 008867fe48
commit 2c6c7a3dcd
37 files changed
+562 -24

No files matched your search

@@ -0,0 +1,5 @@
// expect: reject E7001
// phase: 6
// spec: docs/spec/15-source-language.md §10; docs/spec/10-diagnostics-and-agent-protocol.md §3
module advice
fn main() -> u64 effects [] { var x = 1u64; return x; }
@@ -0,0 +1 @@
[{"kind":"annotate_var_type","hint":"Write an explicit type: `var name: T = expression;`. `let` may infer its type."}]
@@ -0,0 +1,5 @@
// expect: reject E7001
// phase: 6
// spec: docs/spec/15-source-language.md §10; docs/spec/10-diagnostics-and-agent-protocol.md §3
module advice
fn main() -> bool effects [] { return !false; }
@@ -0,0 +1 @@
[{"kind":"boolean_negation","hint":"Aji boolean negation is `not`; integer complement is not boolean negation."}]
@@ -0,0 +1,6 @@
// expect: reject E7001
// phase: 6
// spec: docs/spec/15-source-language.md §10; docs/spec/10-diagnostics-and-agent-protocol.md §3
module advice
fn f(s: ref<u64>) -> void effects [] {}
fn main() -> void effects [] { var x: u64 = 1u64; f(&x); }
@@ -0,0 +1 @@
[{"kind":"borrow_argument","hint":"Write `ref place` or `mut place` for an inline borrow argument.","alternatives":["ref"]}]
@@ -0,0 +1,5 @@
// expect: reject E7001
// phase: 6
// spec: docs/spec/15-source-language.md §10; docs/spec/10-diagnostics-and-agent-protocol.md §3
module advice
fn main() -> void effects [] { var x: u64 = 1u64; let r = &x; }
@@ -0,0 +1 @@
[{"kind":"borrow_binding","hint":"Bind a borrow with `ref name = place;` or `mut name = place;`, rather than a let/var initializer."}]
@@ -0,0 +1,6 @@
// expect: reject E7001
// phase: 6
// spec: docs/spec/15-source-language.md §10; docs/spec/10-diagnostics-and-agent-protocol.md §3
module advice
fn f(s: mut<u64>) -> void effects [] {}
fn main() -> void effects [] { var x: u64 = 1u64; f(&mut x); }
@@ -0,0 +1 @@
[{"kind":"borrow_argument","hint":"Write `ref place` or `mut place` for an inline borrow argument.","alternatives":["mut"]}]
@@ -0,0 +1,21 @@
// expect: run
// result: 42
// phase: 6
// spec: docs/spec/15-source-language.md §4/§5/§10
module advice
fn read(x: ref<u64>) -> u64 effects [] { return *x; }
fn change(x: mut<u64>) -> void effects [] { *x = 42u64; }
fn main() -> u64 effects [] {
var x: u64 = zero;
change(mut x);
let inferred = read(ref x);
let bits = 7u64 & 3u64;
let checked = inferred as! u32;
let wrapped = inferred as% u32;
var bytes: [u8; 3] = zero;
ref part = bytes[0usize..3usize];
if not false and checked == wrapped and bits == 3u64 and part.len == 3usize {
return inferred;
}
return 0u64;
}
@@ -0,0 +1,6 @@
// expect: reject E7001
// phase: 6
// spec: docs/spec/15-source-language.md §10; docs/spec/10-diagnostics-and-agent-protocol.md §3
module advice
fn f(s: slice<u8>) -> void effects [] { ref t = s[1usize..]; }
fn main() -> void effects [] {}
@@ -0,0 +1 @@
[{"kind":"explicit_range_end","hint":"Write both slice bounds: `receiver[start..end]`; choose the upper bound explicitly."}]
@@ -0,0 +1,6 @@
// expect: reject E7005
// phase: 6
// spec: docs/spec/15-source-language.md §10; docs/spec/10-diagnostics-and-agent-protocol.md §3
module advice
fn f(n: u64) -> u32 effects [] { return n as u32; }
fn main() -> void effects [] {}
@@ -0,0 +1 @@
[{"kind":"numeric_cast_modes","hint":"Choose `as!` for a checked conversion (T0006 on overflow) or `as%` for a wrapping conversion.","alternatives":["as!","as%"]}]
@@ -0,0 +1,6 @@
// expect: reject E7001
// phase: 6
// spec: docs/spec/15-source-language.md §10; docs/spec/10-diagnostics-and-agent-protocol.md §3
module advice
fn f(s: mut slice<u8>) -> void effects [] {}
fn main() -> void effects [] {}
@@ -0,0 +1 @@
[{"kind":"slice_mut_type","hint":"Write `slice_mut<T>` for a mutable slice type.","alternatives":["slice_mut<u8>"]}]
@@ -0,0 +1,6 @@
// expect: reject E7001
// phase: 6
// spec: docs/spec/15-source-language.md §10; docs/spec/10-diagnostics-and-agent-protocol.md §3
module advice
fn f(s: ref slice<u8>) -> void effects [] {}
fn main() -> void effects [] {}
@@ -0,0 +1 @@
[{"kind":"slice_ref_type","hint":"Write `slice<T>` for a shared slice type.","alternatives":["slice<u8>"]}]
@@ -0,0 +1,5 @@
// expect: reject E7001
// phase: 6
// spec: docs/spec/15-source-language.md §10; docs/spec/10-diagnostics-and-agent-protocol.md §3
module advice
fn main() -> void effects [] { let xs: [u64; 3] = [zero; 3]; }
@@ -0,0 +1 @@
[{"kind":"zero_storage","hint":"`zero` is only a whole var initializer: `var name: T = zero;`; T must be zeroable."}]