tests: extend rejection twins across public semantic features
This commit is contained in:
1 parent
272aebfd32
commit
06d8a1a76a
32 files changed
+396
-22
No files matched your search
@@ -0,0 +1,11 @@
|
||||
// fs.open_read lacks the explicit fs.read effect; intrinsic, effect and complete suggested_effects agree.
|
||||
// expect: reject E3101
|
||||
// phase: 6
|
||||
// spec: docs/spec/05-effects-and-capabilities.md §9.3
|
||||
// AIR twin: phase2/reject/intrinsic_effect.air
|
||||
module test.source_intrinsic_effect
|
||||
fn f(c: cap<fs.read>, p: slice<u8>) -> void effects [] {
|
||||
let file = fs.open_read(c, p) or trap; // diagnostic here: fs.open_read
|
||||
fs.close(move file) or trap;
|
||||
}
|
||||
fn main() -> u64 effects [] { return 0u64; }
|
||||
@@ -0,0 +1,14 @@
|
||||
// An island result contains atomic<u64>, a foreign mutable edge forbidden by IslandSafe.
|
||||
// expect: reject E2111
|
||||
// phase: 6
|
||||
// spec: docs/spec/03-memory-model.md §22
|
||||
// AIR twin: phase5/reject/island_content.air
|
||||
module test.source_island_content
|
||||
fn main(heap: cap<mem.alloc>) -> u64
|
||||
effects [mem.alloc]
|
||||
{
|
||||
let c = atomic.new(0u64);
|
||||
let isl = island.create(move c, heap) or trap; // diagnostic here: island.create
|
||||
island.destroy(move isl);
|
||||
0
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// Destroying an island while a borrow of its root object is live.
|
||||
// expect: reject E2101
|
||||
// phase: 6
|
||||
// spec: docs/spec/03-memory-model.md §22
|
||||
// AIR twin: phase4/reject/island_destroy_while_borrowed.air
|
||||
module test.source_island_destroy_with_live_child
|
||||
|
||||
fn main(heap: cap<mem.alloc>) -> u64 effects [mem.alloc] {
|
||||
let isl = island.create(1u64, heap) or trap;
|
||||
ref graph = isl;
|
||||
let root = island.root(graph);
|
||||
ref value = island.at(graph, root);
|
||||
island.destroy(move isl); // diagnostic here
|
||||
return *value;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// atomic.load.seq_cst lacks atomic; atomic.new and atomic.take require no effect.
|
||||
// expect: reject E3101
|
||||
// phase: 6
|
||||
// spec: docs/spec/05-effects-and-capabilities.md §13
|
||||
// AIR twin: phase5/reject/missing_atomic_effect.air
|
||||
module test.source_missing_atomic_effect
|
||||
fn main() -> u64
|
||||
effects []
|
||||
{
|
||||
let c = atomic.new(0u64);
|
||||
let x = atomic.load(ref c, seq_cst); // diagnostic here: atomic.load
|
||||
let v = atomic.take(move c);
|
||||
0
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// atomic.load.acquire lacks atomic.weak; the complete suggested effects are [atomic, atomic.weak].
|
||||
// expect: reject E3101
|
||||
// phase: 6
|
||||
// spec: docs/spec/05-effects-and-capabilities.md §13
|
||||
// AIR twin: phase5/reject/missing_weak_effect.air
|
||||
module test.source_missing_weak_effect
|
||||
fn main() -> u64
|
||||
effects [atomic]
|
||||
{
|
||||
let c = atomic.new(0u64);
|
||||
let x = atomic.load(ref c, acquire); // diagnostic here: atomic.load
|
||||
let v = atomic.take(move c);
|
||||
0
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// channel.recv lacks task.wait on a borrowed receiver parameter; no allocation adds another missing effect.
|
||||
// expect: reject E3101
|
||||
// phase: 6
|
||||
// spec: docs/spec/04-concurrency-and-atomics.md
|
||||
// AIR twin: phase3/reject/channels_recv_without_effect.air
|
||||
module test.source_recv_without_effect
|
||||
fn f(rx: mut<receiver<u64>>) -> u64 effects [] {
|
||||
channel.recv(rx) or trap // diagnostic here: channel.recv
|
||||
}
|
||||
fn main() -> u64 effects [] { return 0u64; }
|
||||
@@ -0,0 +1,14 @@
|
||||
// task.spawn lacks the explicit task.spawn effect; the selected missing effect and complete suggested list agree.
|
||||
// expect: reject E3101
|
||||
// phase: 6
|
||||
// spec: docs/spec/04-concurrency-and-atomics.md §33
|
||||
// AIR twin: phase3/reject/tasks_spawn_without_effect.air
|
||||
module test.source_spawn_without_effect
|
||||
fn noop() -> void effects [] {}
|
||||
fn main() -> u64 effects [] {
|
||||
scope sc {
|
||||
let t = task.spawn(sc, noop); // diagnostic here: task.spawn
|
||||
task.join(move t);
|
||||
}
|
||||
0
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// mutex.take consumes a mutex with a live shared borrow, retaining that borrow as the related conflict.
|
||||
// expect: reject E2101
|
||||
// phase: 6
|
||||
// spec: docs/spec/04-concurrency-and-atomics.md §40
|
||||
// AIR twin: phase3/reject/sync_take_while_borrowed.air
|
||||
module test.source_sync_take_while_borrowed
|
||||
fn main() -> u64 effects [] {
|
||||
let m = mutex.make(0u64);
|
||||
ref mr = m;
|
||||
mutex.take(move m) // diagnostic here: mutex.take
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// A safe function calls an effects [unsafe] function without an unsafe or trusted boundary.
|
||||
// expect: reject E6001
|
||||
// phase: 6
|
||||
// spec: docs/spec/13-contracts-and-unsafe.md §6
|
||||
// AIR twin: phase2/reject/unsafe_call_from_safe.air
|
||||
module test.source_unsafe_call_from_safe
|
||||
fn raw() -> void effects [unsafe] {}
|
||||
fn f() -> void effects [] { raw(); } // diagnostic here: raw();
|
||||
fn main() -> u64 effects [] { return 0u64; }
|
||||
@@ -0,0 +1,11 @@
|
||||
// fs.create receives cap<fs.read> instead of required cap<fs.write>; expected/found authority facts agree.
|
||||
// expect: reject E3201
|
||||
// phase: 6
|
||||
// spec: docs/spec/05-effects-and-capabilities.md §10.5
|
||||
// AIR twin: phase2/reject/wrong_capability_kind.air
|
||||
module test.source_wrong_capability_kind
|
||||
fn f(c: cap<fs.read>, p: slice<u8>) -> void effects [fs.write] {
|
||||
let file = fs.create(c, p) or trap; // diagnostic here: fs.create
|
||||
fs.close(move file) or trap;
|
||||
}
|
||||
fn main() -> u64 effects [] { return 0u64; }
|
||||
Reference in new issue
Block a user