cli: validate Copy content of source owning arrays
This commit is contained in:
1 parent
caf3b86e80
commit
cfbe01a16f
42 files changed
+608
-3
No files matched your search
@@ -0,0 +1,86 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10; docs/spec/03-memory-model.md §25
|
||||
module test.own_array_content
|
||||
struct N0 { item: N1 }
|
||||
struct N1 { item: N2 }
|
||||
struct N2 { item: N3 }
|
||||
struct N3 { item: N4 }
|
||||
struct N4 { item: N5 }
|
||||
struct N5 { item: N6 }
|
||||
struct N6 { item: N7 }
|
||||
struct N7 { item: N8 }
|
||||
struct N8 { item: N9 }
|
||||
struct N9 { item: N10 }
|
||||
struct N10 { item: N11 }
|
||||
struct N11 { item: N12 }
|
||||
struct N12 { item: N13 }
|
||||
struct N13 { item: N14 }
|
||||
struct N14 { item: N15 }
|
||||
struct N15 { item: N16 }
|
||||
struct N16 { item: N17 }
|
||||
struct N17 { item: N18 }
|
||||
struct N18 { item: N19 }
|
||||
struct N19 { item: N20 }
|
||||
struct N20 { item: N21 }
|
||||
struct N21 { item: N22 }
|
||||
struct N22 { item: N23 }
|
||||
struct N23 { item: N24 }
|
||||
struct N24 { item: N25 }
|
||||
struct N25 { item: N26 }
|
||||
struct N26 { item: N27 }
|
||||
struct N27 { item: N28 }
|
||||
struct N28 { item: N29 }
|
||||
struct N29 { item: N30 }
|
||||
struct N30 { item: N31 }
|
||||
struct N31 { item: N32 }
|
||||
struct N32 { item: N33 }
|
||||
struct N33 { item: N34 }
|
||||
struct N34 { item: N35 }
|
||||
struct N35 { item: N36 }
|
||||
struct N36 { item: N37 }
|
||||
struct N37 { item: N38 }
|
||||
struct N38 { item: N39 }
|
||||
struct N39 { item: N40 }
|
||||
struct N40 { item: N41 }
|
||||
struct N41 { item: N42 }
|
||||
struct N42 { item: N43 }
|
||||
struct N43 { item: N44 }
|
||||
struct N44 { item: N45 }
|
||||
struct N45 { item: N46 }
|
||||
struct N46 { item: N47 }
|
||||
struct N47 { item: N48 }
|
||||
struct N48 { item: N49 }
|
||||
struct N49 { item: N50 }
|
||||
struct N50 { item: N51 }
|
||||
struct N51 { item: N52 }
|
||||
struct N52 { item: N53 }
|
||||
struct N53 { item: N54 }
|
||||
struct N54 { item: N55 }
|
||||
struct N55 { item: N56 }
|
||||
struct N56 { item: N57 }
|
||||
struct N57 { item: N58 }
|
||||
struct N58 { item: N59 }
|
||||
struct N59 { item: N60 }
|
||||
struct N60 { item: N61 }
|
||||
struct N61 { item: N62 }
|
||||
struct N62 { item: N63 }
|
||||
struct N63 { item: N64 }
|
||||
struct N64 { item: N65 }
|
||||
struct N65 { item: N66 }
|
||||
struct N66 { item: N67 }
|
||||
struct N67 { item: N68 }
|
||||
struct N68 { item: N69 }
|
||||
struct N69 { item: N70 }
|
||||
struct N70 { item: N71 }
|
||||
struct N71 { item: N72 }
|
||||
struct N72 { item: N73 }
|
||||
struct N73 { item: N74 }
|
||||
struct N74 { item: N75 }
|
||||
struct N75 { item: N76 }
|
||||
struct N76 { item: N77 }
|
||||
struct N77 { item: N78 }
|
||||
struct N78 { item: N79 }
|
||||
struct N79 { item: own<u64> }
|
||||
fn unused(p: own_array<N0>) -> void effects [] { trap; }
|
||||
fn main() -> void effects [] {}
|
||||
@@ -0,0 +1,7 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10; docs/spec/03-memory-model.md §25
|
||||
module test.own_array_content
|
||||
enum Linear { Plain, Owned(own<u64>) }
|
||||
fn unused(p: own_array<Linear>) -> void effects [] { trap; }
|
||||
fn main() -> void effects [] {}
|
||||
@@ -0,0 +1,6 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10; docs/spec/03-memory-model.md §25
|
||||
module test.own_array_content
|
||||
struct Bad { items: own_array<own<u64>> }
|
||||
fn main() -> void effects [] {}
|
||||
@@ -0,0 +1,7 @@
|
||||
// expect: reject E7005
|
||||
// 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<[Linear; 2]>) -> void effects [] { trap; }
|
||||
struct Linear { item: own<u64> }
|
||||
fn main() -> void effects [] {}
|
||||
@@ -0,0 +1,6 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10; docs/spec/03-memory-model.md §25
|
||||
module test.own_array_content
|
||||
fn unused<T>(p: own_array<own<T>>) -> void effects [] { trap; }
|
||||
fn main() -> void effects [] {}
|
||||
@@ -0,0 +1,6 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10; docs/spec/03-memory-model.md §25
|
||||
module test.own_array_content
|
||||
struct Bad<T> { items: own_array<own<T>> }
|
||||
fn main() -> void effects [] {}
|
||||
@@ -0,0 +1,7 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10; docs/spec/03-memory-model.md §25
|
||||
module test.own_array_content
|
||||
struct Linear<T> { item: own<T> }
|
||||
fn unused<T>(p: own_array<Linear<T>>) -> void effects [] { trap; }
|
||||
fn main() -> void effects [] {}
|
||||
@@ -0,0 +1,7 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10; docs/spec/03-memory-model.md §25
|
||||
module test.own_array_content
|
||||
struct Node { item: u64 }
|
||||
fn unused(p: own_array<island<Node>>) -> void effects [] { trap; }
|
||||
fn main() -> void effects [] {}
|
||||
@@ -0,0 +1,6 @@
|
||||
// expect: reject E2111
|
||||
// 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: island<own_array<own<u64>>>) -> void effects [] { trap; }
|
||||
fn main() -> void effects [] {}
|
||||
@@ -0,0 +1,7 @@
|
||||
// expect: accept
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.own_array_content
|
||||
struct Node { item: own<u64> }
|
||||
fn unused(p: own_array<iref<Node>>) -> void effects [] { trap; }
|
||||
fn main() -> void effects [] {}
|
||||
@@ -0,0 +1,6 @@
|
||||
// expect: reject E7005
|
||||
// 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: iref<own_array<own<u64>>>) -> void effects [] { trap; }
|
||||
fn main() -> void effects [] {}
|
||||
@@ -0,0 +1,6 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10; docs/spec/03-memory-model.md §25
|
||||
module test.own_array_content
|
||||
fn use() -> void effects [] { var x: own_array<own<u64>> = zero; trap; }
|
||||
fn main() -> void effects [] {}
|
||||
@@ -0,0 +1,9 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.own_array_content
|
||||
struct A { first: B, witness: own<u64> }
|
||||
struct B { back: A }
|
||||
struct Second<X, Y> { item: Y }
|
||||
fn unused<T>(p: own_array<Second<A, B>>, t: T) -> void effects [] { trap; }
|
||||
fn main() -> void effects [] {}
|
||||
@@ -0,0 +1,6 @@
|
||||
// expect: reject E7005
|
||||
// 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<own_array<own<u64>>>) -> void effects [] { trap; }
|
||||
fn main() -> void effects [] {}
|
||||
@@ -0,0 +1,7 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10; docs/spec/03-memory-model.md §25
|
||||
module test.own_array_content
|
||||
struct Pair<T> { item: T }
|
||||
fn unused<T>(p: own_array<Pair<Pair<own<T>>>>) -> void effects [] { trap; }
|
||||
fn main() -> void effects [] {}
|
||||
@@ -0,0 +1,6 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10; docs/spec/03-memory-model.md §25
|
||||
module test.own_array_content
|
||||
fn use(heap: cap<mem.alloc>, value: own<u64>) -> void effects [mem.alloc] { let x = own.array(2, move value, heap) or trap; trap; }
|
||||
fn main() -> void effects [] {}
|
||||
@@ -0,0 +1,6 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.own_array_content
|
||||
fn unused(heap: cap<mem.alloc>, p: ref<u64>) -> void effects [mem.alloc] { let a = [p, p]; let items = own.array(1, a, heap) or trap; trap; }
|
||||
fn main() -> void effects [] {}
|
||||
@@ -0,0 +1,7 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.own_array_content
|
||||
struct Deep { item: [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[own<u64>; 1]; 1]; 1]; 1]; 1]; 1]; 1]; 1]; 1]; 1]; 1]; 1]; 1]; 1]; 1]; 1]; 1]; 1]; 1]; 1]; 1]; 1]; 1]; 1]; 1]; 1]; 1]; 1]; 1]; 1]; 1]; 1]; 1]; 1]; 1]; 1]; 1]; 1]; 1]; 1] }
|
||||
fn unused(heap: cap<mem.alloc>, owner: own<u64>) -> void effects [mem.alloc] { let values = own.array(1, Deep { item: [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[move owner]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]] }, heap) or trap; trap; }
|
||||
fn main() -> void effects [] {}
|
||||
@@ -0,0 +1,6 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.own_array_content
|
||||
fn unused(heap: cap<mem.alloc>, p: ref<u64>) -> void effects [mem.alloc] { let items = own.array(1, p, heap) or trap; trap; }
|
||||
fn main() -> void effects [] {}
|
||||
@@ -0,0 +1,6 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.own_array_content
|
||||
fn unused(heap: cap<mem.alloc>, p: slice<u64>) -> void effects [mem.alloc] { let items = own.array(1, p, heap) or trap; trap; }
|
||||
fn main() -> void effects [] {}
|
||||
@@ -0,0 +1,6 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.own_array_content
|
||||
fn unused(heap: cap<mem.alloc>) -> void effects [mem.alloc] { let items = own.array(1, assert(true), heap) or trap; trap; }
|
||||
fn main() -> void effects [] {}
|
||||
@@ -0,0 +1,6 @@
|
||||
// expect: reject E7005
|
||||
// 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 main() -> void effects [] {}
|
||||
@@ -0,0 +1,7 @@
|
||||
// expect: accept
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10; docs/spec/03-memory-model.md §25
|
||||
module test.own_array_content
|
||||
struct Phantom<T> { item: u64 }
|
||||
fn unused<T>(p: own_array<Phantom<own<T>>>) -> void effects [] { trap; }
|
||||
fn main() -> void effects [] {}
|
||||
@@ -0,0 +1,6 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10; docs/spec/03-memory-model.md §25
|
||||
module test.own_array_content
|
||||
struct Node { items: own_array<Node> }
|
||||
fn main() -> void effects [] {}
|
||||
@@ -0,0 +1,7 @@
|
||||
// expect: reject E1003
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10; docs/spec/03-memory-model.md §25
|
||||
module test.own_array_content
|
||||
struct Node { items: [Node; 1] }
|
||||
fn unused(p: own_array<Node>) -> void effects [] { trap; }
|
||||
fn main() -> void effects [] {}
|
||||
@@ -0,0 +1,7 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.own_array_content
|
||||
struct S<A, B, C> { a: A, n: [S<B, C, A>; 1] }
|
||||
fn unused<T>(p: own_array<S<u64, u64, own<u64>>>, t: T) -> void effects [] { trap; }
|
||||
fn main() -> void effects [] {}
|
||||
@@ -0,0 +1,7 @@
|
||||
// expect: accept
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.own_array_content
|
||||
struct S<A, B, C> { a: A, n: [S<B, C, A>; 1] }
|
||||
fn unused<T>(p: own_array<S<u64, u64, u64>>, t: T) -> void effects [] { trap; }
|
||||
fn main() -> void effects [] {}
|
||||
@@ -0,0 +1,10 @@
|
||||
// expect: accept
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.own_array_content
|
||||
struct region { x: u64 }
|
||||
struct stream { x: u64 }
|
||||
struct listener { x: u64 }
|
||||
fn unused<T>(a: own_array<region>, b: own_array<stream>, c: own_array<listener>, t: T) -> void effects [] { trap; }
|
||||
fn concrete(a: own_array<region>) -> void effects [] { trap; }
|
||||
fn main() -> void effects [] {}
|
||||
@@ -0,0 +1,7 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10; docs/spec/03-memory-model.md §25
|
||||
module test.own_array_content
|
||||
fn bad<T>() -> own_array<T> effects [] { trap; }
|
||||
fn use() -> void effects [] { let x = bad::<own<u64>>(); trap; }
|
||||
fn main() -> void effects [] {}
|
||||
@@ -0,0 +1,6 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10; docs/spec/03-memory-model.md §25
|
||||
module test.own_array_content
|
||||
fn unused<T, F: fn(own_array<own<T>>) -> void effects []>() -> void effects [] { trap; }
|
||||
fn main() -> void effects [] {}
|
||||
@@ -0,0 +1,9 @@
|
||||
// expect: run
|
||||
// result: 42
|
||||
// grant: heap=mem.alloc:4096
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10; docs/spec/03-memory-model.md §25
|
||||
module test.own_array_content
|
||||
struct Plain { item: u64 }
|
||||
fn make<T: Copy>(value: T, heap: cap<mem.alloc>) -> own_array<T> effects [mem.alloc] { return own.array(2, move value, heap) or trap; }
|
||||
fn main(heap: cap<mem.alloc>) -> u64 effects [mem.alloc] { let values = make::<Plain>(Plain { item: 21u64 }, heap); let n = { ref items = values; items[0].item + items[1].item }; own.free(move values); return n; }
|
||||
@@ -0,0 +1,8 @@
|
||||
// expect: accept
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.own_array_content
|
||||
struct Node { item: own<u64> }
|
||||
struct Plain { values: [u64; 2] }
|
||||
fn unused<T, F: fn(own_array<T>) -> void effects []>(a: own_array<T>, b: own_array<Plain>, c: own_array<iref<Node>>) -> void effects [] { trap; }
|
||||
fn main() -> void effects [] {}
|
||||
Reference in new issue
Block a user