Skip to content

Commit

Permalink
rustc: Pushdown type params for tag patterns. Closes #363
Browse files Browse the repository at this point in the history
  • Loading branch information
brson committed May 31, 2011
1 parent 973b93e commit c7e3f88
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/comp/middle/typeck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1171,10 +1171,20 @@ mod pushdown {
let ty_param_substs_and_ty res_t = demand::full(scx, pat.span,
expected, tt, tps, NO_AUTODEREF);

// TODO: push down type from "expected".
write::ty_fixup(scx, ann.id,
ty::ann_to_ty_param_substs_opt_and_ty
(scx.fcx.ccx.tcx.node_types, ann));
auto ty_params_subst = ty::ann_to_ty_param_substs_opt_and_ty
(scx.fcx.ccx.tcx.node_types, ann);

auto ty_params_opt;
alt (ty_params_subst._0) {
case (none[vec[ty::t]]) {
ty_params_opt = none[vec[ty::t]];
}
case (some[vec[ty::t]](?tps)) {
ty_params_opt = some[vec[ty::t]](tag_tps);
}
}

write::ty_fixup(scx, ann.id, tup(ty_params_opt, tt));
}
}
}
Expand Down
15 changes: 15 additions & 0 deletions src/test/run-pass/alt-pattern-no-type-params.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// xfail-stage0

tag maybe[T] {
nothing;
just(T);
}

fn foo(maybe[int] x) {
alt (x) {
case (nothing) {log_err "A";}
case (just(?a)) {log_err "B";}
}
}

fn main() {}

0 comments on commit c7e3f88

Please sign in to comment.