cli: reject non-value operands without aborting lowering
This commit is contained in:
1 parent
bc5412dadd
commit
dcd5f1f702
83 files changed
+1042
-38
No files matched your search
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> u64 effects [] { return stop() + 1u64; }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> u64 effects [] { return 1u64 + stop(); }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> u64 effects [] { return 1u64 + nothing(); }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> u64 effects [] { let x = stop() and true; return 42; }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> u64 effects [] { let x = true and stop(); return 42; }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main(heap: cap<mem.alloc>) -> void effects [mem.alloc] { let x = own.array(stop(), 1u64, heap) or trap; trap; }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> u64 effects [] { assert(stop()); return 42; }
|
||||
@@ -0,0 +1,12 @@
|
||||
// expect: run
|
||||
// trap: T0001
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §4/§10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> u64 effects [] { var x: u64 = 0; x = stop(); }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> u64 effects [unsafe] { assume(stop()); return 42; }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> void effects [] { let a = atomic.new(1u64); let (old, ok) = atomic.compare_exchange(ref a, 1u64, stop(), seq_cst, seq_cst); trap; }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> void effects [] { let a = atomic.new(1u64); let (old, ok) = atomic.compare_exchange(ref a, stop(), 1u64, seq_cst, seq_cst); trap; }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> void effects [] { let a = atomic.new(1u64); atomic.store(ref a, stop(), relaxed); trap; }
|
||||
@@ -0,0 +1,8 @@
|
||||
// expect: run
|
||||
// result: 42
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §4/§10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn pick(p: ref<u64>, c: bool) -> ref<u64> from p effects [] { if c { return p; } else { stop(); } }
|
||||
fn main() -> u64 effects [] { let x = 42u64; ref p = x; ref q = pick(p, true); return *q; }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main(heap: cap<mem.alloc>) -> void effects [mem.alloc] { let b = buffer.new<u64>(2usize, heap) or trap; mut m = b; buffer.push(m, stop()) or trap; trap; }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main(heap: cap<mem.alloc>) -> void effects [mem.alloc] { let b = buffer.new<u64>(2usize, heap) or trap; mut m = b; buffer.reserve(m, stop(), heap) or trap; trap; }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main(heap: cap<mem.alloc>) -> void effects [mem.alloc] { let x = buffer.new<u64>(stop(), heap) or trap; trap; }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> u64 effects [] { return take({ return 42u64; }); }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> u64 effects [] { return take(stop()); }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> u64 effects [] { return take(nothing()); }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> u64 effects [] { return take(if true { stop() } else { stop() }); }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> u64 effects [] { return two(stop(), missing); }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> u64 effects [] { return take(match Choice::None { Choice::Some(x) => stop(), Choice::None => stop(), }); }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> u64 effects [] { return two(1u64, stop()); }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main(heap: cap<mem.alloc>) -> void effects [mem.alloc] { let c = cap.narrow.budget(heap, stop()) or trap; trap; }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main(heap: cap<mem.alloc>) -> void effects [mem.alloc, task.wait] { match channel.make<u64>(1usize, heap) { ok(tx, rx) => { channel.send(tx, stop()) or trap; trap; } err(e) => { trap; } } }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main(heap: cap<mem.alloc>) -> void effects [mem.alloc] { let x = channel.make<u64>(stop(), heap) or trap; trap; }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> u64 effects [] { let x = 1u64 < stop(); return 42; }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> u64 effects [] { let x = Choice::Some(stop()); return 42; }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> u64 effects [] { let x = Choice::Some(nothing()); return 42; }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> void effects [] { var x: Pair = Pair { a: 1u64, b: 2u64 }; mut p = x; p.a = stop(); }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> u64 effects [] { for i in 0usize..stop() {} return 42; }
|
||||
@@ -0,0 +1,12 @@
|
||||
// expect: run
|
||||
// trap: T0001
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> void effects [] { var x: u64 = 0; { ref p = x; } x = stop(); }
|
||||
@@ -0,0 +1,12 @@
|
||||
// expect: run
|
||||
// result: 42
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> u64 effects [] { var x: u64 = 42; { ref p = x; } if false { x = stop(); } return x; }
|
||||
@@ -0,0 +1,12 @@
|
||||
// expect: run
|
||||
// trap: T0001
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> void effects [] { var x: u64 = 42; { ref p = x; } { var x: u64 = stop(); } }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7006
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> void effects [] { var x: u64 = stop(); ref p = x; }
|
||||
@@ -0,0 +1,12 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn generic<T: Copy>(x: T) -> T effects [] { return x; }
|
||||
fn main() -> u64 effects [] { return generic::<u64>(stop()); }
|
||||
@@ -0,0 +1,12 @@
|
||||
// expect: run
|
||||
// result: 42
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §4/§10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> u64 effects [] { let x = if true { 42u64 } else { stop() }; return x; }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> u64 effects [] { if stop() { return 42; } else { return 0; } }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> u64 effects [] { if nothing() { return 42; } else { return 0; } }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> u64 effects [] { var a: [u64; 2] = [21u64; 2]; return a[stop()]; }
|
||||
@@ -0,0 +1,12 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn read(p: ref<u64>) -> u64 effects [] { return *p; }
|
||||
fn main() -> u64 effects [] { var a: [u64; 2] = [21u64; 2]; return read(ref a[stop()]); }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> void effects [] { var x: [u64; 2] = [1u64; 2]; x[0usize] = stop(); }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> u64 effects [] { var a: [u64; 2] = [21u64; 2]; return a[nothing()]; }
|
||||
@@ -0,0 +1,12 @@
|
||||
// expect: run
|
||||
// trap: T0001
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §4/§10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> u64 effects [] { var x: u64 = stop(); }
|
||||
@@ -0,0 +1,13 @@
|
||||
// expect: run
|
||||
// result: 42
|
||||
// grant: heap=mem.alloc:64
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §4/§10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main(heap: cap<mem.alloc>) -> u64 effects [mem.alloc] { let a = own.new(42u64, heap) or trap; let b = if true { move a } else { stop() }; return own.take(move b); }
|
||||
@@ -0,0 +1,12 @@
|
||||
// expect: run
|
||||
// result: 42
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §4/§10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> u64 effects [] { return match Choice::Some(42u64) { Choice::Some(x) => x, Choice::None => stop(), }; }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> i64 effects [] { return -stop(); }
|
||||
@@ -0,0 +1,12 @@
|
||||
// expect: run
|
||||
// trap: T0001
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §4/§10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> u64 effects [] { stop(); }
|
||||
@@ -0,0 +1,12 @@
|
||||
// expect: run
|
||||
// trap: T0001
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §4/§10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> u64 effects [] { stop() }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> u64 effects [] { let x = not stop(); return 42; }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> u64 effects [] { let x = not nothing(); return 42; }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> u64 effects [] { let x = stop() or true; return 42; }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> u64 effects [] { let x = false or stop(); return 42; }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> u64 effects [] { var a: [u64; 2] = [21u64; 2]; ref s = a[0usize..stop()]; return 42; }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> u64 effects [] { var a: [u64; 2] = [21u64; 2]; ref s = a[stop()..2usize]; return 42; }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main(heap: cap<mem.alloc>) -> void effects [mem.alloc] { let a = region.create(heap) or trap; ref r = a; let x = region.array(r, stop(), 1u64) or trap; trap; }
|
||||
@@ -0,0 +1,12 @@
|
||||
// expect: run
|
||||
// trap: T0001
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §4/§10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> u64 effects [] { return stop(); }
|
||||
@@ -0,0 +1,12 @@
|
||||
// expect: run
|
||||
// trap: T0001
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §4/§10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> void effects [] { return stop(); }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main(heap: cap<mem.alloc>) -> void effects [mem.alloc, task.wait] { match channel.make<u64>(1usize, heap) { ok(tx, rx) => { mut t = tx; select { send(t, stop()) { ok => {} closed(x) => {} } cancelled(x) => { trap; } } trap; } err(e) => { trap; } } }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main(heap: cap<mem.alloc>) -> void effects [mem.alloc, task.wait] { match channel.make<u64>(1usize, heap) { ok(tx, rx) => { select { send(tx, stop()) { ok => {} closed(x) => {} } cancelled(x) => { trap; } } trap; } err(e) => { trap; } } }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> u64 effects [] { var a: [u64; 2] = [21u64; 2]; ref s = a; let (left, right) = s.split_at(stop()); return 42; }
|
||||
@@ -0,0 +1,12 @@
|
||||
// expect: run
|
||||
// result: 42
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §4/§10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> u64 effects [] { nothing(); scope s { nothing(); } shield { nothing(); } loop { break; } return 42; }
|
||||
@@ -0,0 +1,12 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn use<F: fn(u64) -> u64 effects []>(x: u64) -> u64 effects [] { return F(x); }
|
||||
fn main() -> u64 effects [] { return use::<fn take>(stop()); }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> void effects [] { var x: u64 = 0; mut p = x; *p = stop(); }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> u64 effects [] { var x: u64 = 42; { ref p = x; } if false { mut p = x; *p = stop(); } return x; }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> u64 effects [] { let x = Pair { a: stop(), b: 1u64 }; return 42; }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> u64 effects [] { let x = Pair { b: missing, a: stop() }; return 42; }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> u64 effects [] { let x = Pair { a: nothing(), b: 1u64 }; return 42; }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> void effects [] { var x: Pair = Pair { a: 1u64, b: 2u64 }; x.missing = stop(); }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> void effects [] { var x: u64 = 0; x[0usize] = stop(); }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> void effects [] { var x: u64 = 0; *x = stop(); }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> void effects [] { var x: u64 = 0; x.field = stop(); }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> void effects [] { missing.field = stop(); }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> u64 effects [] { var x: u64 = 0; let old = value.swap(mut x, stop()); return 42; }
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §10
|
||||
module test.nonvalue_operands
|
||||
fn stop() -> never effects [] { trap; }
|
||||
fn nothing() -> void effects [] {}
|
||||
fn take(x: u64) -> u64 effects [] { return x; }
|
||||
fn two(x: u64, y: u64) -> u64 effects [] { return x + y; }
|
||||
struct Pair { a: u64, b: u64 }
|
||||
enum Choice { Some(u64), None }
|
||||
fn main() -> u64 effects [] { while stop() {} return 42; }
|
||||
@@ -0,0 +1,103 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Never operands reject; divergent statements retain control flow and effects."""
|
||||
import json
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import tempfile
|
||||
|
||||
REPO = Path(__file__).resolve().parents[2]
|
||||
AJI = REPO / 'zig-out/bin/aji'
|
||||
CORPUS = REPO / 'tests/conformance/source/nonvalue_operands'
|
||||
checks = 0
|
||||
|
||||
|
||||
def cli(*args, code=0):
|
||||
global checks
|
||||
result = subprocess.run([str(AJI), *map(str, args)], capture_output=True, text=True)
|
||||
assert result.returncode == code, (args, result.returncode, result.stdout, result.stderr)
|
||||
checks += 1
|
||||
return result.stdout
|
||||
|
||||
|
||||
def rejection(path, token, fields, *args, function='fn main', expected_file=None, code='E7005'):
|
||||
error = json.loads(cli('check', *args, code=1))
|
||||
assert error['code'] == code, error
|
||||
for key, value in fields.items():
|
||||
assert error[key] == value, error
|
||||
lines = path.read_text().splitlines()
|
||||
line = next(i for i, text in enumerate(lines, 1) if text.startswith(function))
|
||||
assert (error['file'], error['line'], error['col']) == (
|
||||
expected_file or str(path), line, lines[line - 1].index(token) + 1), error
|
||||
assert 'air_line' not in error and 'air_col' not in error, error
|
||||
for command in ('lower', 'run', 'report', 'explore'):
|
||||
assert json.loads(cli(command, *args, code=1)) == error
|
||||
|
||||
|
||||
bool_cases = {'and_left', 'and_right', 'or_left', 'or_right', 'not',
|
||||
'if_condition', 'while_condition', 'assert', 'assume'}
|
||||
usize_cases = {'index', 'index_argument', 'range_low', 'range_high', 'for_high',
|
||||
'split', 'array_size', 'buffer_size', 'buffer_reserve',
|
||||
'channel_size', 'cap_budget', 'region_size'}
|
||||
tokens = {'call_if': 'if true', 'call_match': 'match Choice::None',
|
||||
'call_block': '{ return 42u64;', 'frame_initialization_unreachable': 'ref p = x'}
|
||||
|
||||
with tempfile.TemporaryDirectory(prefix='aji-nonvalue-operands-') as directory:
|
||||
root = Path(directory)
|
||||
for source in sorted(CORPUS.glob('*.aji')):
|
||||
name, text = source.stem, source.read_text()
|
||||
if text.startswith('// expect: reject E7005'):
|
||||
base = name.removesuffix('_void')
|
||||
wanted = 'a stored value' if name.startswith('target_') else 'bool' if base in bool_cases else 'usize' if base in usize_cases else 'i64' if base == 'negate' else 'u64'
|
||||
found = 'void' if name.endswith('_void') else 'never'
|
||||
rejection(source, tokens.get(name, 'nothing()' if found == 'void' else 'stop()'),
|
||||
{'expected': wanted, 'found': found}, source)
|
||||
elif text.startswith('// expect: reject E7006'):
|
||||
rejection(source, tokens[name], {'reason': 'unreachable'}, source, code='E7006')
|
||||
formatted = root / f'{name}.aji'
|
||||
formatted.write_text(cli('fmt', source))
|
||||
cli('fmt', '--check', formatted)
|
||||
assert cli('fmt', formatted) == formatted.read_text()
|
||||
if not text.startswith('// expect: run'):
|
||||
continue
|
||||
air = cli('lower', source)
|
||||
assert cli('lower', formatted) == air
|
||||
raw = root / f'{name}.air'
|
||||
raw.write_text(air)
|
||||
cli('check', source)
|
||||
cli('check', raw)
|
||||
trapped = '// trap: T0001' in text
|
||||
grants = ['--grant', 'heap=mem.alloc:64'] if name == 'linear_branch' else []
|
||||
exit_code = 4 if trapped else 0
|
||||
expected = json.loads(cli('run', '--fuel', '100000', *grants, source, code=exit_code))
|
||||
actual = json.loads(cli('run', '--fuel', '100000', *grants, raw, code=exit_code))
|
||||
if trapped:
|
||||
assert expected['status'] == 'trapped' and expected['code'] == 'T0001', expected
|
||||
assert expected['source_location']['file'] == str(source), expected
|
||||
expected.pop('source_location')
|
||||
else:
|
||||
assert expected['value'] == 42, expected
|
||||
assert actual == expected, (name, actual, expected)
|
||||
result = root / f'{name}.json'
|
||||
cli('run', '--profile', 'hosted', '--fuel', '100000', *grants, '--result-file', result,
|
||||
source, code=exit_code)
|
||||
hosted = json.loads(result.read_text())
|
||||
if trapped:
|
||||
assert hosted['status'] == 'trapped' and hosted['code'] == 'T0001', hosted
|
||||
else:
|
||||
assert hosted['value'] == 42, hosted
|
||||
|
||||
entry, library, manifest = (root / name for name in ('main.aji', 'values.aji', 'aji.toml'))
|
||||
entry.write_text('module app\nimport lib.values;\nfn main() -> u64 effects [] { return lib.values.bad::<u64>(); }\n')
|
||||
library.write_text('module lib.values\nfn stop() -> never effects [] { trap; }\n'
|
||||
'fn id<T: Copy>(x: T) -> T effects [] { return x; }\n'
|
||||
'fn bad<T: Copy>() -> T effects [] { return id::<T>(stop()); }\n')
|
||||
manifest.write_text('[package]\nname = "values"\nversion = "1"\nentry = "main.aji"\n[modules]\nlib.values = "values.aji"\n')
|
||||
rejection(library, 'stop()', {'expected': 'u64', 'found': 'never'}, '--manifest', manifest,
|
||||
function='fn bad', expected_file='values.aji')
|
||||
library.write_text(library.read_text().replace('id::<T>(stop())', 'id::<T>(42u64)'))
|
||||
assert json.loads(cli('run', '--manifest', manifest))['value'] == 42
|
||||
entry.write_text('module app\nfn main() -> u64 effects [] { return 42; }\n')
|
||||
library.write_text(library.read_text().replace('id::<T>(42u64)', 'id::<T>(stop())'))
|
||||
assert json.loads(cli('run', '--manifest', manifest))['value'] == 42
|
||||
|
||||
print(f'nonvalue operand CLI integration passed ({checks} checks)')
|
||||
Reference in new issue
Block a user