tests: audit source boundaries and cancellation join twins
This commit is contained in:
1 parent
5371eb7a2f
commit
50d1bb2c4b
20 files changed
+363
-10
No files matched your search
@@ -139,6 +139,8 @@ The SB litmus test requires the interpreter not to forbid `r1=0, r2=0` under rel
|
||||
|
||||
`f32`/`f64` are listed in spec 02 §1 but reserved by spec 07 §8.4: AIR rejects their use with `E0006`, reason `reserved_type`, and `.aji` 0.1 exposes no floating-point types. They do not create a determinism gap in currently accepted programs. This question remains open for future activation: NaN payloads, fused operations, rounding mode and denormals need explicit rules before floating point can participate in deterministic replay.
|
||||
|
||||
Source naming also needs an activation decision: `.aji` currently accepts nominal declarations such as `struct f64 { value: u8 }`; their uses lower to `@f64`, not the reserved AIR primitive `f64`. An undeclared `f64` is an ordinary E7002 unknown name. Future primitive activation needs an explicit source-name and backward-compatibility policy for these existing nominal programs.
|
||||
|
||||
## Q-017 — Replay file format
|
||||
|
||||
Spec 11 §4 mentions `.ajr` files without a format or compatibility rule.
|
||||
|
||||
@@ -320,8 +320,8 @@ Validation: unit tests and Zig formatting pass; full conformance is 1,655/1,655.
|
||||
|
||||
## P6-7 public rejection-twin audit (2026-10-08)
|
||||
|
||||
Verified same-code coverage is 77/199. Audited pairs cover owner/file/receiver leaks, use after transfer, authority/effects, unsafe calls, Send/Share, live task loans, mutex guards, graph content/access, atomic orders/effects, linear unpack/projection, buffer views/failure, static calls and recursive layouts. Independent markers verify instruction, outcome-block and function/type declaration positions. An island-destroy fixture retains a child object borrow and its subsequent load; witnesses preserve discarded-unpack and returned-buffer-failure contexts. Failed-send closed/cancelled edges converge at one source error, matching AIR's merged failure path. E3101 callee identities resolve to their explicit flat effect sets. Send/Share argument comparisons preserve the complete rejected parameter type while normalizing worker/SSA names; source/raw identities and related values remain identical. The producer lookup recognizes island.borrow as a borrow. Three buffer pairs retain shared-view push exclusion, reserve effects and capability kind. Error-value and borrowed-element analogues keep their source-prescribed E7xxx codes; missing feature/dependency headers and reserved primitive floats are AIR-only. A user nominal f64 lowers to @f64 and does not exercise the reserved primitive rule. The legacy reserved_feature comment describes its actual missing_dependency rejection; its body and permanent name are unchanged. The inventory retains 68 pending, 23 E7xxx analogues and 31 AIR-only cases, all still unmet under Q-053. P6-7 remains doing.
|
||||
Verified same-code coverage is 79/199. Audited pairs cover owner/file/receiver leaks, use after transfer, authority/effects, unsafe calls, Send/Share, live task loans, mutex guards, graph content/access, atomic orders/effects, linear unpack/projection, buffer views/failure, static calls and recursive layouts. Independent markers verify instruction, outcome-block and function/type declaration positions. An island-destroy fixture retains a child object borrow and its subsequent load; witnesses preserve discarded-unpack and returned-buffer-failure contexts. Failed-send closed/cancelled edges converge at one source error, matching AIR's merged failure path. E3101 callee identities resolve to their explicit flat effect sets. Send/Share argument comparisons preserve the complete rejected parameter type while normalizing worker/SSA names; source/raw identities and related values remain identical. The producer lookup recognizes island.borrow as a borrow. Three buffer pairs retain shared-view push exclusion, reserve effects and capability kind. Error-value and borrowed-element analogues keep their source-prescribed E7xxx codes; missing feature/dependency headers and reserved primitive floats are AIR-only. A user nominal f64 lowers to @f64 and does not exercise the reserved primitive rule. Module-level cancellation activated by a shield helper preserves the join-wait rule; a taken mutex preserves E3001 on its next borrow. Linear match/unpack, buffer operand/outcome and file-mode analogues keep their prescribed source diagnostics. Legacy nested-owner/resource signatures require the now-published linear_aggregates header, generated automatically in source. Q-016 records the nominal f64 naming decision needed before primitive activation. The legacy reserved_feature comment describes its actual missing_dependency rejection; its body and permanent name are unchanged. The inventory retains 42 pending, 34 E7xxx analogues and 44 AIR-only cases, all still unmet under Q-053. P6-7 remains doing.
|
||||
|
||||
The diamond budget pair requires an identical named type-declaration table so equal-sized flat arrays cannot replace its shared nominal graph. Early cycle pairs, which produce no canonical AIR, pin both manually audited files with SHA-256; edits require a fresh context review while compiled diagnostics and positions remain checked. Exact opcode counts preserve the shared-view push function shape; an operand witness links the reported conflicting borrow to buffer.view, excluding ended decoys and views of other buffers. These are explicit fixture witnesses, not a second type/layout evaluator or proof of the manual audit.
|
||||
|
||||
Validation: full conformance is 1,680/1,680; unit tests, Zig formatting, all 41 checker regressions and the 77-pair source/AIR position check pass. All 38 source reject_twins fixtures pass collection before every instruction; source coverage remains 121/121. The completion gate still rejects partial coverage. Claude independently audited the new buffer pairs, six E7xxx analogues and five AIR-only cases. Its exclusive-view, ended-view and other-buffer decoy findings are covered by regressions and the opcode/operand witnesses. No compiler, verifier, runtime, normative rule, diagnostic code or reference bundle changes.
|
||||
Validation: full conformance is 1,688/1,688; unit tests, Zig formatting, all 41 checker regressions and the 79-pair source/AIR position check pass. All 46 source reject_twins fixtures pass collection before every instruction; source coverage remains 121/121. The completion gate still rejects partial coverage. Claude independently audited the two new same-code pairs, eleven E7xxx analogues and thirteen AIR-only classifications, including exact structured fields, markers and governing rules. Earlier exclusive-view, ended-view and other-buffer decoys remain covered by regressions and the opcode/operand witnesses. No compiler, verifier, runtime, normative rule, diagnostic code or reference bundle changes.
|
||||
@@ -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
|
||||
|
||||
@@ -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; } }
|
||||
Reference in new issue
Block a user