From 3060eadcbabba50fd6a5d633fea710b6b6bed614 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Mon, 2 May 2011 14:28:35 -0700 Subject: Check well-formedness of constraints Check that the operand in a constraint is an explicit name, and that the operands are all local variables or literals. Still need to check that the name refers to a pure function. --- src/test/compile-fail/not-a-pred-3.rs | 15 +++++++++++++++ src/test/compile-fail/not-pred-args.rs | 11 +++++++++++ 2 files changed, 26 insertions(+) create mode 100644 src/test/compile-fail/not-a-pred-3.rs create mode 100644 src/test/compile-fail/not-pred-args.rs (limited to 'src/test') diff --git a/src/test/compile-fail/not-a-pred-3.rs b/src/test/compile-fail/not-a-pred-3.rs new file mode 100644 index 00000000..ea1b6cc0 --- /dev/null +++ b/src/test/compile-fail/not-a-pred-3.rs @@ -0,0 +1,15 @@ +// -*- rust -*- +// xfail-boot + +// error-pattern: expected the constraint name + +obj f () { + fn g (int q) -> bool { + ret true; + } +} + +fn main() { + auto z = f (); + check (z.g)(42); // should fail to typecheck, as z.g isn't an explicit name +} diff --git a/src/test/compile-fail/not-pred-args.rs b/src/test/compile-fail/not-pred-args.rs new file mode 100644 index 00000000..c92b4ff9 --- /dev/null +++ b/src/test/compile-fail/not-pred-args.rs @@ -0,0 +1,11 @@ +// -*- rust -*- +// xfail-boot + +// error-pattern: Constraint args must be + +fn f(int q) -> bool { ret true; } + +fn main() { +// should fail to typecheck, as pred args must be slot variables or literals + check f(42 * 17); +} -- cgit v1.2.3