summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorTim Chevalier <chevalier@alum.wellesley.edu>2011-07-11 17:26:40 -0700
committerTim Chevalier <chevalier@alum.wellesley.edu>2011-07-11 17:32:00 -0700
commite1620def9f4e1da73f798f5deb3d8dbe410fce90 (patch)
tree9be1f3027af3c566630cbade4f9e4898b2ad99e0 /src/test
parent9fe03b3c556eddd99887e7968f9757f7bdf91cc1 (diff)
downloadrust-e1620def9f4e1da73f798f5deb3d8dbe410fce90.tar.gz
rust-e1620def9f4e1da73f798f5deb3d8dbe410fce90.zip
In typeck, check for dynamically sized by-value arguments to thunks
A check in trans didn't have a corresponding check in typeck, causing
some programs (to wit, compile-fail/chan-parameterized-args.rs - part of this
commit) to fail with an assertion failure in trans instead of a type error.
Fixed it. In short, arguments that are future thunk arguments (any spawn
arguments, and _ arguments in bind) need to either not contain type params
or type vars, or be by-reference.

Closes #665.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/compile-fail/bind-parameterized-args.rs10
-rw-r--r--src/test/compile-fail/chan-parameterized-args.rs18
2 files changed, 28 insertions, 0 deletions
diff --git a/src/test/compile-fail/bind-parameterized-args.rs b/src/test/compile-fail/bind-parameterized-args.rs
new file mode 100644
index 00000000000..5e2dd24fb28
--- /dev/null
+++ b/src/test/compile-fail/bind-parameterized-args.rs
@@ -0,0 +1,10 @@
+// xfail-stage0
+// error-pattern:Bind arguments with types containing parameters must be
+fn main() {
+  fn echo[T](int c, vec[T] x) {
+  }
+  
+  let fn(vec[int]) -> () y = bind echo(42, _);
+
+  y([1]);
+}
diff --git a/src/test/compile-fail/chan-parameterized-args.rs b/src/test/compile-fail/chan-parameterized-args.rs
new file mode 100644
index 00000000000..78c9a743c75
--- /dev/null
+++ b/src/test/compile-fail/chan-parameterized-args.rs
@@ -0,0 +1,18 @@
+// xfail-stage0
+// error-pattern:Spawn arguments with types containing parameters must be
+fn main() {
+// Similar to bind-parameterized-args
+    fn echo[T](chan[T] c, chan[chan[T]] oc) {
+        let port[T] p = port();
+        oc <| chan(p);
+
+        auto x;
+        p |> x;
+        c <| x;
+    }
+
+    auto p = port[int]();
+    auto p2 = port[chan[int]]();
+
+    spawn echo(chan(p), chan(p2));
+}
\ No newline at end of file