Two tests that the typechecker correctly unifies type arguments in patterns with their expected tag types
This commit is contained in:
parent
971b5d5151
commit
b42bb2cff2
2 changed files with 52 additions and 0 deletions
27
src/test/compile-fail/pattern-tyvar-2.rs
Normal file
27
src/test/compile-fail/pattern-tyvar-2.rs
Normal file
|
@ -0,0 +1,27 @@
|
|||
// -*- rust -*-
|
||||
// xfail-stage0
|
||||
|
||||
use std;
|
||||
import std::option;
|
||||
import std::option::some;
|
||||
|
||||
// error-pattern: mismatched types
|
||||
|
||||
tag bar {
|
||||
t1((), option::t[vec[int]]);
|
||||
t2;
|
||||
}
|
||||
|
||||
fn foo(bar t) -> int {
|
||||
alt (t) {
|
||||
case (t1(_, some(?x))) {
|
||||
ret (x * 3);
|
||||
}
|
||||
case (_) {
|
||||
fail;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
25
src/test/compile-fail/pattern-tyvar.rs
Normal file
25
src/test/compile-fail/pattern-tyvar.rs
Normal file
|
@ -0,0 +1,25 @@
|
|||
// -*- rust -*-
|
||||
use std;
|
||||
import std::option;
|
||||
import std::option::some;
|
||||
|
||||
// error-pattern: mismatched types
|
||||
|
||||
tag bar {
|
||||
t1((), option::t[vec[int]]);
|
||||
t2;
|
||||
}
|
||||
|
||||
fn foo(bar t) {
|
||||
alt (t) {
|
||||
case (t1(_, some[int](?x))) {
|
||||
log x;
|
||||
}
|
||||
case (_) {
|
||||
fail;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue