about summary refs log tree commit diff
path: root/src/comp
diff options
context:
space:
mode:
authorTim Chevalier <chevalier@alum.wellesley.edu>2012-01-12 16:23:24 -0800
committerTim Chevalier <chevalier@alum.wellesley.edu>2012-01-12 16:51:07 -0800
commit565ea068ca6deb50c5866475508c538dc7e3acee (patch)
tree50588ed6241d1970e10faf04bf1d3653ff7d1327 /src/comp
parent8818f42b19efbf8832c856058519644a8657b04c (diff)
downloadrust-565ea068ca6deb50c5866475508c538dc7e3acee.tar.gz
rust-565ea068ca6deb50c5866475508c538dc7e3acee.zip
Add type parameters when checking wildcard patterns
For some reason, wildcard patterns were never getting type parameter
substitutions attached. This would cause an assertion failure when
checking a wildcard pattern that matches against a tag with
polymorphic type (not sure why this didn't come up before). Fixed it.
(The diff and test case may be easier to understand than this note
:P)

Closes #1503.
Diffstat (limited to 'src/comp')
-rw-r--r--src/comp/middle/typeck.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs
index 0ecff4260fb..e3718933caa 100644
--- a/src/comp/middle/typeck.rs
+++ b/src/comp/middle/typeck.rs
@@ -1264,7 +1264,18 @@ fn valid_range_bounds(from: @ast::expr, to: @ast::expr) -> bool {
 fn check_pat(fcx: @fn_ctxt, map: ast_util::pat_id_map, pat: @ast::pat,
              expected: ty::t) {
     alt pat.node {
-      ast::pat_wild. { write::ty_only_fixup(fcx, pat.id, expected); }
+      ast::pat_wild. {
+          alt structure_of(fcx, pat.span, expected) {
+                  ty::ty_tag(_, expected_tps) {
+                      let path_tpt = {substs: some(expected_tps),
+                                      ty: expected};
+                      write::ty_fixup(fcx, pat.id, path_tpt);
+                  }
+                  _ {
+                      write::ty_only_fixup(fcx, pat.id, expected);
+                  }
+              }
+      }
       ast::pat_lit(lt) {
         check_expr_with(fcx, lt, expected);
         write::ty_only_fixup(fcx, pat.id, expr_ty(fcx.ccx.tcx, lt));