tests: extend audited rejection twins through tasks and locks
This commit is contained in:
1 parent
e4aacef48c
commit
272aebfd32
16 files changed
+157
-13
No files matched your search
@@ -3,10 +3,11 @@
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md
|
||||
module demo.leak
|
||||
// AIR twin: phase2/reject/own_leak.air
|
||||
|
||||
fn main(heap: cap<mem.alloc>) -> u64
|
||||
effects [mem.alloc]
|
||||
{
|
||||
let x = own.new(1u64, heap) or trap;
|
||||
7
|
||||
7 // diagnostic here
|
||||
}
|
||||
@@ -3,10 +3,11 @@
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md
|
||||
module demo.missingeffect
|
||||
// AIR twin: phase2/reject/alloc_without_effect.air
|
||||
|
||||
fn main(heap: cap<mem.alloc>) -> u64
|
||||
effects []
|
||||
{
|
||||
let x = own.new(1u64, heap) or trap;
|
||||
let x = own.new(1u64, heap) or trap; // diagnostic here: own.new
|
||||
own.take(move x)
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md
|
||||
module demo.useaftermove
|
||||
// AIR twin: phase2/reject/own_use_after_move.air
|
||||
|
||||
fn sink(o: own<u64>) -> void
|
||||
effects []
|
||||
@@ -21,5 +22,5 @@ effects [mem.alloc]
|
||||
{
|
||||
let x = own.new(1u64, heap) or trap;
|
||||
sink(move x);
|
||||
read(ref x)
|
||||
read(ref x) // diagnostic here: ref
|
||||
}
|
||||
@@ -3,9 +3,10 @@
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md
|
||||
module demo.resourceleak
|
||||
// AIR twin: phase2/reject/resource_leak.air
|
||||
|
||||
fn main(src: cap<fs.read>) -> void
|
||||
effects [fs.read]
|
||||
{
|
||||
{ // diagnostic here
|
||||
let f = fs.open_read(src, b"/in/a") or trap;
|
||||
}
|
||||
@@ -3,11 +3,12 @@
|
||||
// phase: 6
|
||||
// spec: docs/spec/13-contracts-and-unsafe.md
|
||||
module demo.unsafeboundary
|
||||
// AIR twin: phase2/reject/unsafe_outside_boundary.air
|
||||
|
||||
fn get(s: slice<u64>, i: usize) -> u64
|
||||
effects []
|
||||
{
|
||||
ref unchecked e = s[i];
|
||||
ref unchecked e = s[i]; // diagnostic here
|
||||
*e
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md
|
||||
module demo.access_lent
|
||||
// AIR twin: phase3/reject/tasks_access_lent.air
|
||||
|
||||
fn bump(s: slice_mut<u64>) -> void
|
||||
effects []
|
||||
@@ -20,7 +21,7 @@ effects [task.spawn]
|
||||
let (l, r) = s.split_at(2);
|
||||
scope sc {
|
||||
let a = task.spawn(sc, bump, l);
|
||||
seen = l[0];
|
||||
seen = l[0]; // diagnostic here: l[0]
|
||||
task.join(move a);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,11 +3,12 @@
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md
|
||||
module demo.receiver_leak
|
||||
// AIR twin: phase3/reject/channels_receiver_leak.air
|
||||
|
||||
fn main(heap: cap<mem.alloc>) -> u64
|
||||
effects [mem.alloc, task.wait]
|
||||
{
|
||||
match channel.make<u64>(1, heap) {
|
||||
match channel.make<u64>(1, heap) { // diagnostic here
|
||||
ok(tx, rx) => {
|
||||
channel.close_sender(move tx);
|
||||
0
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md
|
||||
module demo.same_mut_twice
|
||||
// AIR twin: phase3/reject/tasks_same_mut_twice.air
|
||||
|
||||
fn bump(s: slice_mut<u64>) -> void
|
||||
effects []
|
||||
@@ -18,7 +19,7 @@ effects [task.spawn]
|
||||
mut s = buf;
|
||||
scope sc {
|
||||
let a = task.spawn(sc, bump, s);
|
||||
let b = task.spawn(sc, bump, s);
|
||||
let b = task.spawn(sc, bump, s); // diagnostic here: task.spawn
|
||||
task.join(move a);
|
||||
task.join(move b);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md
|
||||
module demo.scope_unjoined
|
||||
// AIR twin: phase3/reject/tasks_scope_end_unjoined.air
|
||||
|
||||
fn work() -> u64
|
||||
effects []
|
||||
@@ -13,7 +14,7 @@ effects []
|
||||
fn main() -> u64
|
||||
effects [task.spawn]
|
||||
{
|
||||
scope sc {
|
||||
scope sc { // diagnostic here: {
|
||||
let t = task.spawn(sc, work);
|
||||
}
|
||||
0
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md
|
||||
module demo.call_waiting_function
|
||||
// AIR twin: phase3/reject/sync_call_waiting_function.air
|
||||
|
||||
fn pause() -> void
|
||||
effects [task.wait]
|
||||
@@ -14,7 +15,7 @@ effects [task.wait]
|
||||
{
|
||||
let m = mutex.make(0u64);
|
||||
lock ref m as c {
|
||||
pause();
|
||||
pause(); // diagnostic here
|
||||
*c = 1;
|
||||
} cancelled {}
|
||||
mutex.take(move m)
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md
|
||||
module demo.lock_twice
|
||||
// AIR twin: phase3/reject/sync_lock_twice.air
|
||||
|
||||
fn main() -> u64
|
||||
effects [task.wait]
|
||||
@@ -10,7 +11,7 @@ effects [task.wait]
|
||||
let a = mutex.make(0u64);
|
||||
let b = mutex.make(0u64);
|
||||
lock ref a as x {
|
||||
lock ref b as y {
|
||||
lock ref b as y { // diagnostic here
|
||||
*y = *x;
|
||||
} cancelled {}
|
||||
} cancelled {}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md
|
||||
module demo.wait_while_locked
|
||||
// AIR twin: phase3/reject/sync_wait_while_locked.air
|
||||
|
||||
fn main(heap: cap<mem.alloc>) -> u64
|
||||
effects [mem.alloc, task.wait]
|
||||
@@ -11,7 +12,7 @@ effects [mem.alloc, task.wait]
|
||||
match channel.make<u64>(1, heap) {
|
||||
ok(tx, rx) => {
|
||||
lock ref m as c {
|
||||
*c = channel.recv(rx) or trap;
|
||||
*c = channel.recv(rx) or trap; // diagnostic here: channel.recv
|
||||
} cancelled {}
|
||||
channel.close_sender(move tx);
|
||||
channel.close_receiver(move rx) or trap;
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
// A direct local store conflicts with a live shared view.
|
||||
// expect: reject E2101
|
||||
// phase: 6
|
||||
// spec: docs/spec/08-verifier.md §11.2
|
||||
// AIR twin: phase1/reject/related_borrow_live.air
|
||||
module test.source_store_with_live_borrow
|
||||
|
||||
fn main() -> u64 effects [] {
|
||||
var data: u64 = 0;
|
||||
ref view = data;
|
||||
data = 2; // diagnostic here
|
||||
return *view;
|
||||
}
|
||||
Reference in new issue
Block a user