P6A-11, P6A-12: malformed lowering is an internal compiler error; source type-check completeness

P6A-11: when a .aji module passed the frontend but its AIR does not parse
(E0001-E0005) or has invalid SSA/CFG (E5001, E5002), the result is one
E7900 source.internal_compiler_error at the source construct, with the
AIR code in air_code; semantic codes (E0006 included) are unaffected.
Unit test injects the checkpoint's `ret %` defect.

P6A-12: source-decidable type errors are E7005 at the source:
- `as` checks lossless widening with the verifier's own rule (shared
  function), and that both sides are integers
- slice.copy element types; own.free / region.destroy operand types
- element rules of channel.make<T> and mutex.make (no borrow, scope,
  task, shield or guard, at any depth)
Probing every source position found no other E1001/E1002 leak. The old
test encoding the previous rule (verifier_widen, E1002) is replaced by
typecheck/lossy_widen (E7005); 9 typecheck tests. Spec 15 §10 states the
frontend/verifier boundary.
This commit is contained in:
dev committed 2026-10-05 18:10:53 +03:00
1 parent 154c39865f
commit 748eddf4e5
16 files changed
+249 -14

No files matched your search

@@ -1,12 +0,0 @@
// The frontend does not duplicate the verifier: a lossy `as` lowers to cast.widen and the verifier rejects it (E1002).
// expect: reject E1002
// phase: 6
// spec: docs/spec/15-source-language.md
module demo.widen
fn main() -> u8
effects []
{
let big: u64 = 1;
return big as u8;
}
@@ -0,0 +1,13 @@
// Arithmetic operands have the same integer type; there is no implicit conversion.
// expect: reject E7005
// phase: 6
// spec: docs/spec/15-source-language.md
module demo.binary_mixed_widths
fn main() -> u64
effects []
{
let a = 1u8;
let b = 2u64;
b + a
}
@@ -0,0 +1,17 @@
// A call argument of the wrong type is E7005 at the argument, not E1001 after lowering.
// expect: reject E7005
// phase: 6
// spec: docs/spec/15-source-language.md
module demo.call_argument
fn f(x: u64) -> u64
effects []
{
x
}
fn main() -> u64
effects []
{
f(true)
}
@@ -0,0 +1,12 @@
// Casts convert between integer types.
// expect: reject E7005
// phase: 6
// spec: docs/spec/15-source-language.md
module demo.cast_non_integer
fn main() -> u64
effects []
{
let a = true;
a as u64
}
@@ -0,0 +1,18 @@
// A channel element contains no borrow (spec 04 §38.1), checked at the source.
// expect: reject E7005
// phase: 6
// spec: docs/spec/15-source-language.md
module demo.channel_borrow_element
fn main(heap: cap<mem.alloc>) -> u64
effects [mem.alloc]
{
match channel.make<ref<u64>>(1, heap) {
ok(tx, rx) => {
channel.close_sender(move tx);
channel.close_receiver(move rx) or trap;
0
}
err(e) => { trap; }
}
}
@@ -0,0 +1,12 @@
// `as` only widens without loss (the verifier's rule, checked at the source): a narrowing `as` is E7005 at the cast.
// expect: reject E7005
// phase: 6
// spec: docs/spec/15-source-language.md
module demo.lossy_widen
fn main() -> u8
effects []
{
let big: u64 = 1;
return big as u8;
}
@@ -0,0 +1,14 @@
// A mutex's content contains no borrow, checked at the source.
// expect: reject E7005
// phase: 6
// spec: docs/spec/15-source-language.md
module demo.mutex_borrow_content
fn main() -> u64
effects []
{
var x: u64 = 0;
ref r = x;
let m = mutex.make(r);
0
}
@@ -0,0 +1,13 @@
// `own.free` takes an owner.
// expect: reject E7005
// phase: 6
// spec: docs/spec/15-source-language.md
module demo.own_free_non_owner
fn main() -> u64
effects []
{
let x = 1u64;
own.free(x);
0
}
@@ -0,0 +1,19 @@
// A shared borrow is passed where an exclusive one is expected.
// expect: reject E7005
// phase: 6
// spec: docs/spec/15-source-language.md
module demo.ref_for_mut
fn g(r: mut<u64>) -> void
effects []
{
*r = 1;
}
fn main() -> u64
effects []
{
var x: u64 = 0;
g(ref x);
x
}
@@ -0,0 +1,14 @@
// `slice.copy` copies between slices of the same element type.
// expect: reject E7005
// phase: 6
// spec: docs/spec/15-source-language.md
module demo.slice_copy_elements
fn main() -> u64
effects []
{
var a: [u8; 4] = zero;
var b: [u64; 4] = zero;
slice.copy(mut a, ref b);
0
}