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.
This commit is contained in:
parent
9fe03b3c55
commit
e1620def9f
4 changed files with 77 additions and 11 deletions
10
src/test/compile-fail/bind-parameterized-args.rs
Normal file
10
src/test/compile-fail/bind-parameterized-args.rs
Normal file
|
|
@ -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]);
|
||||
}
|
||||
18
src/test/compile-fail/chan-parameterized-args.rs
Normal file
18
src/test/compile-fail/chan-parameterized-args.rs
Normal file
|
|
@ -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));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue