mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
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
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…
Reference in New Issue
Block a user