tests: audit task argument identities and source error boundaries
This commit is contained in:
1 parent
fd92604f36
commit
2742867ef7
18 files changed
+344
-20
No files matched your search
@@ -8,7 +8,7 @@ fn main() -> void effects [task.spawn, task.wait] {
|
||||
let data = [42u64, 2u64];
|
||||
ref s = data;
|
||||
scope sc {
|
||||
let t = task.spawn(sc, first, s);
|
||||
let t = task.spawn(sc, first, s); // diagnostic here: task.spawn
|
||||
task.cancel(t);
|
||||
trap;
|
||||
}
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §9, §18
|
||||
module test.effects.ordinary_unused
|
||||
fn unused() -> void effects [unknown] {}
|
||||
fn unused() -> void effects [unknown] {} // diagnostic here
|
||||
fn main() -> u64 effects [] { return 42; }
|
||||
@@ -14,7 +14,7 @@ fn main() -> u64
|
||||
effects []
|
||||
{
|
||||
let s = State::Busy(3);
|
||||
return match s {
|
||||
return match s { // diagnostic here: match
|
||||
State::Ready => 0,
|
||||
State::Busy(n) => n,
|
||||
};
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md
|
||||
module demo.not_share
|
||||
// AIR twin: phase3/reject/tasks_not_share.air
|
||||
|
||||
fn look(r: ref<region>) -> u64
|
||||
effects []
|
||||
@@ -18,7 +19,7 @@ effects [mem.alloc, task.spawn]
|
||||
{
|
||||
ref arena = r;
|
||||
scope sc {
|
||||
let t = task.spawn(sc, look, arena);
|
||||
let t = task.spawn(sc, look, arena); // diagnostic here: task.spawn
|
||||
v = task.join(move t);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// phase: 6
|
||||
// spec: docs/spec/03-memory-model.md
|
||||
module demo.lend_island
|
||||
// AIR twin: phase4/reject/island_lend_task.air
|
||||
|
||||
fn read(g: ref<island<u64>>) -> u64
|
||||
effects []
|
||||
@@ -20,7 +21,7 @@ effects [mem.alloc, task.spawn]
|
||||
{
|
||||
ref g = isl;
|
||||
scope sc {
|
||||
let t = task.spawn(sc, read, g);
|
||||
let t = task.spawn(sc, read, g); // diagnostic here: task.spawn
|
||||
v = task.join(move t);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
// A struct containing capability authority cannot be zero initialized, using zero_not_zeroable.
|
||||
// expect: reject E7006
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §4/§10
|
||||
module test.source_analogue_capability_not_zeroable
|
||||
struct H { c: cap<fs.read> }
|
||||
fn main() -> u64 effects [] { var h: H = zero; return 0u64; } // diagnostic here: var h
|
||||
@@ -0,0 +1,8 @@
|
||||
// A duplicate function declaration rejects before AIR with the duplicate_declaration reason registered by spec 15 §10 in reference/error-codes.md.
|
||||
// expect: reject E7006
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.source_analogue_duplicate_function
|
||||
fn f() -> void effects [] {}
|
||||
fn f() -> void effects [] {} // diagnostic here
|
||||
fn main() -> u64 effects [] { return 0u64; }
|
||||
@@ -0,0 +1,6 @@
|
||||
// The integer literal 256 cannot fit u8; source checks its typed range before AIR under the general source-decided type rule.
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.source_analogue_literal_out_of_range
|
||||
fn main() -> u64 effects [] { let x: u8 = 256; return 0u64; } // diagnostic here: 256
|
||||
@@ -0,0 +1,7 @@
|
||||
// u64 cannot be returned from a u32 function; this type-decided error is E7005.
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.source_analogue_return_type_mismatch
|
||||
fn f() -> u32 effects [] { return 1u64; } // diagnostic here: 1u64
|
||||
fn main() -> u64 effects [] { return 0u64; }
|
||||
@@ -0,0 +1,7 @@
|
||||
// zero initialization requires a zeroable type; an enum rejects with registered zero_not_zeroable.
|
||||
// expect: reject E7006
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §4/§10
|
||||
module test.source_analogue_zero_enum
|
||||
enum E { A, B }
|
||||
fn main() -> u64 effects [] { var e: E = zero; return 0u64; } // diagnostic here: var e
|
||||
@@ -0,0 +1,20 @@
|
||||
// An exclusive view of a task handle is not Send.
|
||||
// expect: reject E4001
|
||||
// phase: 6
|
||||
// spec: docs/spec/04-concurrency-and-atomics.md §35
|
||||
// AIR twin: phase3/reject/tasks_not_send.air
|
||||
module test.source_task_non_send
|
||||
|
||||
fn noop() -> u8 effects [] { return 0u8; }
|
||||
fn hold(handle: mut<task<u8>>) -> void effects [] {}
|
||||
fn main() -> void effects [task.spawn] {
|
||||
scope sc {
|
||||
let first = task.spawn(sc, noop);
|
||||
{
|
||||
mut lent = first;
|
||||
let second = task.spawn(sc, hold, lent); // diagnostic here: task.spawn
|
||||
task.join(move second);
|
||||
}
|
||||
task.join(move first);
|
||||
}
|
||||
}
|
||||
@@ -2,5 +2,5 @@
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10; docs/spec/07-air.md §8.8
|
||||
module test.type_positions
|
||||
struct Bad { p: ref<u64> }
|
||||
struct Bad { p: ref<u64> } // diagnostic here: ref<u64>
|
||||
fn main() -> void effects [] {}
|
||||
@@ -7,7 +7,7 @@ module demo.channel_borrow_element
|
||||
fn main(heap: cap<mem.alloc>) -> u64
|
||||
effects [mem.alloc]
|
||||
{
|
||||
match channel.make<ref<u64>>(1, heap) {
|
||||
match channel.make<ref<u64>>(1, heap) { // diagnostic here: ref<u64>
|
||||
ok(tx, rx) => {
|
||||
channel.close_sender(move tx);
|
||||
channel.close_receiver(move rx) or trap;
|
||||
|
||||
Reference in new issue
Block a user