tests: audit source boundaries and cancellation join twins

This commit is contained in:
dev committed 2026-10-08 21:35:58 +03:00
1 parent 5371eb7a2f
commit 50d1bb2c4b
20 files changed
+363 -10

No files matched your search

@@ -1,3 +1,4 @@
; The outcome header first rejects own_array<own<u64>> because own_array content must be Copy.
; expect: reject E1001
; phase: 6
; spec: docs/spec/07a-air-instructions.md Dynamic buffers
@@ -1,4 +1,4 @@
; own<own<u64>> nests linear values.
; Nested owners require the published linear_aggregates feature, absent here.
; expect: reject E0006
; phase: 2
; spec: docs/spec/03-memory-model.md
@@ -1,4 +1,4 @@
; own<file<read>> would let own.free drop an open file.
; Owning resource content requires linear_aggregates, absent here; own.free still cannot discard linear content.
; expect: reject E0006
; phase: 2
; spec: docs/spec/03-memory-model.md
@@ -1,4 +1,4 @@
; Resources in aggregates need the reserved feature linear_aggregates.
; Resources in aggregates require the published linear_aggregates feature, absent here.
; expect: reject E0006
; phase: 2
; spec: docs/spec/06-resources-and-errors.md
+262
View File
@@ -1049,6 +1049,268 @@
"kind": "air_only",
"spec": "docs/spec/15-source-language.md \u00a73",
"rule": "Source has no built-in f32/f64 type (spec 07 \u00a78.4). An undeclared f64 spelling is an ordinary E7002 unknown name; a user nominal f64 lowers to @f64 and cannot produce the reserved AIR primitive f64. Neither tests the reserved_type rule. Spec 15 \u00a71 restricts source to published features."
},
"phase3/reject/cancel_join_needs_wait.air": {
"kind": "same_code",
"site": "instruction",
"spec": "docs/spec/04-concurrency-and-atomics.md \u00a737.4",
"rule": "In a module declaring cancellation, task.join requires task.wait. Source declares cancellation via a shield helper in the same module, preserving main's task.spawn contract and its suggested effects.",
"required_ops": {
"task.spawn": 1,
"task.join": 1
}
},
"phase3/reject/sync_use_after_take.air": {
"kind": "same_code",
"site": "instruction",
"spec": "docs/spec/04-concurrency-and-atomics.md \u00a732",
"rule": "A mutex is borrowed again after mutex.take consumed it; the source lock begins with that same borrow.ref.",
"required_ops": {
"mutex.take": 1
}
},
"phase2/reject/own_nested.air": {
"kind": "air_only",
"spec": "docs/spec/15-source-language.md \u00a79",
"rule": "The existing AIR rejects a missing feature header, not the type itself. Source lowering automatically includes capabilities or the published linear_aggregates feature and its closure for these types."
},
"phase2/reject/own_of_resource.air": {
"kind": "air_only",
"spec": "docs/spec/15-source-language.md \u00a79",
"rule": "The existing AIR rejects a missing feature header, not the type itself. Source lowering automatically includes capabilities or the published linear_aggregates feature and its closure for these types."
},
"phase2/reject/resource_in_struct.air": {
"kind": "air_only",
"spec": "docs/spec/15-source-language.md \u00a79",
"rule": "The existing AIR rejects a missing feature header, not the type itself. Source lowering automatically includes capabilities or the published linear_aggregates feature and its closure for these types."
},
"phase2/reject/cap_without_feature.air": {
"kind": "air_only",
"spec": "docs/spec/15-source-language.md \u00a79",
"rule": "The existing AIR rejects a missing feature header, not the type itself. Source lowering automatically includes capabilities or the published linear_aggregates feature and its closure for these types."
},
"phase5/reject/struct_field.air": {
"kind": "air_only",
"spec": "docs/spec/15-source-language.md \u00a79",
"rule": "The existing AIR rejects a missing feature header, not the type itself. Source lowering automatically includes capabilities or the published linear_aggregates feature and its closure for these types."
},
"phase2/reject/unsafe_trusted_without_feature.air": {
"kind": "air_only",
"spec": "docs/spec/15-source-language.md \u00a72",
"rule": "A source trusted clause always rejects E7006 as forbidden, independently of obligation or effects. The AIR trusted declaration rules for an empty obligation, an unsafe boundary contract or a missing feature therefore cannot be isolated in source."
},
"phase2/reject/unsafe_trusted_declares_unsafe.air": {
"kind": "air_only",
"spec": "docs/spec/15-source-language.md \u00a72",
"rule": "A source trusted clause always rejects E7006 as forbidden, independently of obligation or effects. The AIR trusted declaration rules for an empty obligation, an unsafe boundary contract or a missing feature therefore cannot be isolated in source."
},
"phase2/reject/unsafe_empty_obligation.air": {
"kind": "air_only",
"spec": "docs/spec/15-source-language.md \u00a72",
"rule": "A source trusted clause always rejects E7006 as forbidden, independently of obligation or effects. The AIR trusted declaration rules for an empty obligation, an unsafe boundary contract or a missing feature therefore cannot be isolated in source."
},
"linear/enum_incomplete.air": {
"kind": "source_error",
"spec": "docs/spec/15-source-language.md \u00a716",
"rule": "A linear enum match move omits Maybe::none; source rejects the incomplete consuming match with E7004 before emitting enum.take.",
"analogues": [
{
"source": "source/reject_twins/analogue_enum_incomplete.aji",
"codes": [
"E7004"
],
"fields": {
"missing": "Maybe::none"
}
}
]
},
"linear/unpack_count.air": {
"kind": "source_error",
"spec": "docs/spec/15-source-language.md \u00a716",
"rule": "array.unpack of a one-element linear array binds two components. Source rejects the authored extra binding before emitting an AIR continuation.",
"analogues": [
{
"source": "source/reject_twins/analogue_unpack_count.aji",
"codes": [
"E7005"
],
"fields": {}
}
]
},
"buffers/metadata_owner.air": {
"kind": "source_error",
"spec": "docs/spec/15-source-language.md \u00a717",
"rule": "buffer.len receives an owner instead of the required named ref/mut buffer binding; source checks that operand form before AIR.",
"analogues": [
{
"source": "source/reject_twins/analogue_metadata_owner.aji",
"codes": [
"E7005"
],
"fields": {}
}
]
},
"buffers/push_continuation_count.air": {
"kind": "source_error",
"spec": "docs/spec/15-source-language.md \u00a717",
"rule": "The authored buffer.push success arm binds an extra value although ok has zero bindings. This source outcome-arity error rejects before AIR.",
"analogues": [
{
"source": "source/reject_twins/analogue_push_continuation_count.aji",
"codes": [
"E7005"
],
"fields": {
"outcome": "ok",
"expected": "0"
}
}
]
},
"buffers/new_count_type.air": {
"kind": "source_error",
"spec": "docs/spec/15-source-language.md \u00a710",
"rule": "buffer.new receives a u64 capacity instead of usize; the source operand type rule preserves both types in E7005.",
"analogues": [
{
"source": "source/reject_twins/analogue_new_count_type.aji",
"codes": [
"E7005"
],
"fields": {
"expected": "usize",
"found": "u64"
}
}
]
},
"linear/enum_switch.air": {
"kind": "source_error",
"spec": "docs/spec/15-source-language.md \u00a716",
"rule": "An ordinary match on a named linear enum needs explicit move; source rejects E7003 before the invalid enum.switch.",
"analogues": [
{
"source": "source/linear/plain_enum_match.aji",
"codes": [
"E7003"
],
"fields": {
"name": "old"
}
}
]
},
"buffers/new_return_type.air": {
"kind": "source_error",
"spec": "docs/spec/15-source-language.md \u00a710",
"rule": "Despite the AIR filename, the first rejection is the non-Copy content of own_array<own<u64>> on its outcome block parameter. Source checks that same content rule at the annotation.",
"analogues": [
{
"source": "source/own_array_content/owner.aji",
"codes": [
"E7005"
],
"fields": {
"constraint": "Copy",
"type_constructor": "own_array"
}
}
]
},
"phase2/reject/wrong_file_mode.air": {
"kind": "source_error",
"spec": "docs/spec/15-source-language.md \u00a710",
"rule": "fs.write_all requires a writable file; source rejects file<read> at its operand before emitting the invalid intrinsic.",
"analogues": [
{
"source": "source/layer6/reject/wrong_mode.aji",
"codes": [
"E7005"
],
"fields": {
"expected": "file<write> or file<append>",
"found": "file<read>"
}
}
]
},
"phase2/reject/unknown_capability_kind.air": {
"kind": "source_error",
"spec": "docs/spec/15-source-language.md \u00a710",
"rule": "An unregistered capability kind rejects E7002 in source. AIR uses root and the existing source analogue uses unknown; neither can be registered by a program.",
"analogues": [
{
"source": "source/diagnostic_envelope/capability_kind_unknown.aji",
"codes": [
"E7002"
],
"fields": {
"capability_kind": "unknown"
}
}
]
},
"buffers/reserve_count_type.air": {
"kind": "source_error",
"spec": "docs/spec/15-source-language.md \u00a710",
"rule": "buffer.reserve receives a u64 capacity instead of usize; source reports E7005 for the same operand type mismatch.",
"analogues": [
{
"source": "source/reject_twins/analogue_buffer_reserve_count_type.aji",
"codes": [
"E7005"
],
"fields": {
"expected": "usize",
"found": "u64"
}
}
]
},
"buffers/push_type.air": {
"kind": "source_error",
"spec": "docs/spec/15-source-language.md \u00a710",
"rule": "buffer.push into a buffer<own<u64>> receives a u64 value; source rejects the content type mismatch with E7005.",
"analogues": [
{
"source": "source/reject_twins/analogue_buffer_push_type.aji",
"codes": [
"E7005"
],
"fields": {
"expected": "own<u64>",
"found": "u64"
}
}
]
},
"linear/array_count.air": {
"kind": "air_only",
"spec": "docs/spec/15-source-language.md \u00a71",
"rule": "A source list literal fixes its own array length and supplies every element. The AIR mismatch between declared array.make length and input count is generated mechanics; a source annotation mismatch is a different type rule."
},
"buffers/pop_return_type.air": {
"kind": "air_only",
"spec": "docs/spec/15-source-language.md \u00a71",
"rule": "The pop success binding type is generated from buffer<T>. Source outcome bindings cannot annotate an incompatible type; a later let annotation mismatch is a different rule."
},
"buffers/free_return_type.air": {
"kind": "air_only",
"spec": "docs/spec/15-source-language.md \u00a71",
"rule": "The free error binding is generated as the returned buffer<T>. Source cannot annotate that outcome binding as own<T>; a later variable annotation mismatch is a different rule."
},
"error_values/unknown_family.air": {
"kind": "air_only",
"spec": "docs/spec/15-source-language.md \u00a76",
"rule": "Only registered built-in error families lower to error.const. An undeclared family spelling in source is ordinary enum-name resolution (E7002); a user enum of that name lowers to enum.make @Name, never an unregistered error.const family."
},
"error_values/frozen_enum_make.air": {
"kind": "air_only",
"spec": "docs/spec/15-source-language.md \u00a76",
"rule": "Built-in error expressions lower to error.const with error_values and its closure. Source cannot choose the frozen legacy enum.make spelling for a built-in error family; user nominal enums use a distinct @Name type."
}
}
}
@@ -2,4 +2,4 @@
// phase: 6
// spec: docs/spec/10-diagnostics-and-agent-protocol.md §2
module diagnostic.unknown_capability
fn main(c: cap<unknown>) -> void effects [] {}
fn main(c: cap<unknown>) -> void effects [] {} // diagnostic here: cap<unknown>
@@ -8,6 +8,6 @@ fn main(src: cap<fs.read>) -> void
effects [fs.read, fs.write]
{
let f = fs.open_read(src, b"/in/a") or trap;
fs.write_all(f, b"x") or trap;
fs.write_all(f, b"x") or trap; // diagnostic here: f, b
fs.close(move f) or trap;
}
@@ -2,6 +2,7 @@
// expect: reject E3001
// phase: 6
// spec: docs/spec/15-source-language.md
// AIR twin: phase3/reject/sync_use_after_take.air
module demo.use_after_take
fn main() -> u64
@@ -9,7 +10,7 @@ effects [task.wait]
{
let m = mutex.make(1u64);
let v = mutex.take(move m);
lock ref m as c {
lock ref m as c { // diagnostic here: m as c
*c = 2;
} cancelled {}
v
@@ -12,5 +12,5 @@ fn main(heap: cap<mem.alloc>) -> u64 effects [mem.alloc] {
var value: Maybe<own<u64>> = Maybe::<own<u64>>::some(move owner);
let old = replace(mut value);
match move value { Maybe::<own<u64>>::none => {}, Maybe::<own<u64>>::some(extra) => { own.free(move extra); } }
match old { Maybe::<own<u64>>::some(part) => { return own.take(move part); } Maybe::<own<u64>>::none => { return 0; } }
match old { Maybe::<own<u64>>::some(part) => { return own.take(move part); } Maybe::<own<u64>>::none => { return 0; } } // diagnostic here: old {
}
@@ -2,5 +2,5 @@
// phase: 6
// spec: docs/spec/15-source-language.md §10; docs/spec/03-memory-model.md §25
module test.own_array_content
fn unused(p: own_array<own<u64>>) -> void effects [] { trap; }
fn unused(p: own_array<own<u64>>) -> void effects [] { trap; } // diagnostic here: own<u64>>) ->
fn main() -> void effects [] {}
@@ -0,0 +1,13 @@
// expect: reject E7005
// phase: 6
// spec: docs/spec/15-source-language.md §10
module test.buffers
fn main(heap: cap<mem.alloc>) -> u64 effects [mem.alloc] {
let data = buffer.new<own<u64>>(1, heap) or trap;
{
mut b = data;
buffer.push(b, 42u64) or trap; // diagnostic here: 42u64
}
buffer.free(move data) or trap;
return 42;
}
@@ -0,0 +1,10 @@
// expect: reject E7005
// phase: 6
// spec: docs/spec/15-source-language.md §10
module test.buffers
fn main(heap: cap<mem.alloc>) -> u64 effects [mem.alloc] {
let data = buffer.new<u64>(1, heap) or trap;
{ mut b = data; buffer.reserve(b, 2u64, heap) or trap; } // diagnostic here: 2u64
buffer.free(move data) or trap;
return 42;
}
@@ -0,0 +1,11 @@
// expect: reject E7004
// phase: 6
// spec: docs/spec/15-source-language.md §6, §16
module test.linear
enum Maybe { some(own<u64>), none }
fn main(heap: cap<mem.alloc>) -> u64 effects [mem.alloc] {
let owner = own.new(42u64, heap) or trap;
let slot = Maybe::some(move owner);
match move slot { Maybe::some(extra) => { own.free(move extra); } } // diagnostic here
return 0;
}
@@ -0,0 +1,10 @@
// expect: reject E7005
// phase: 6
// spec: docs/spec/15-source-language.md §17
module test.buffers
fn main(heap: cap<mem.alloc>) -> u64 effects [mem.alloc] {
let data = buffer.new<u64>(1, heap) or trap;
let n = buffer.len(data); // diagnostic here: data);
buffer.free(move data) or trap;
return 42;
}
@@ -0,0 +1,9 @@
// expect: reject E7005
// phase: 6
// spec: docs/spec/15-source-language.md §10, §17
module test.buffers
fn main(heap: cap<mem.alloc>) -> u64 effects [mem.alloc] {
let data = buffer.new<u64>(1u64, heap) or trap; // diagnostic here: 1u64
buffer.free(move data) or trap;
return 42;
}
@@ -0,0 +1,8 @@
// expect: reject E7005
// phase: 6
// spec: docs/spec/15-source-language.md §2, §17
module buffer.contract
fn bad(b: mut<buffer<u64>>) -> void effects [] {
match buffer.push(b, 42u64) { ok(extra) => { trap; }, err(original) => { trap; } } // diagnostic here: ok(extra)
}
fn main() -> u64 effects [] { return 42; }
@@ -0,0 +1,10 @@
// expect: reject E7005
// phase: 6
// spec: docs/spec/15-source-language.md §16
module test.linear
fn bad(owner: own<u64>) -> u64 effects [] {
let items = [move owner];
let (part, other) = array.unpack(move items); // diagnostic here
return own.take(move part);
}
fn main() -> u64 effects [] { return 42; }
@@ -0,0 +1,16 @@
// A shield in another function declares cancellation for the whole module.
// task.join therefore requires task.wait even though main has no cancellation point.
// expect: reject E3101
// phase: 6
// spec: docs/spec/04-concurrency-and-atomics.md §37.4; docs/spec/15-source-language.md §7
// AIR twin: phase3/reject/cancel_join_needs_wait.air
module test.cancel_join_needs_wait
fn main() -> u8 effects [task.spawn] {
scope sc {
let t = task.spawn(sc, w);
let r = task.join(move t); // diagnostic here: task.join
return r;
}
}
fn w() -> u8 effects [] { return 0u8; }
fn cancellation_probe() -> void effects [] { shield { return; } }