Skip to content

Commit 3c060be

Browse files
committed
---
yaml --- r: 1343 b: refs/heads/master c: d7f1181 h: refs/heads/master i: 1341: d1f66f2 1339: 8ca8d12 1335: 2c60317 1327: 7d50055 1311: cd11ec9 1279: 6706a1b v: v3
1 parent b64791d commit 3c060be

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 3e613c1648141ac757d1f0608ad845686ebbe97e
2+
refs/heads/master: d7f118135b8a3eee7c8788052542e6e1c205a3d9

trunk/src/comp/middle/ty.rs

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,24 @@ fn count_ty_params(@t ty) -> uint {
551551
ret _vec.len[ast.def_id](*param_ids);
552552
}
553553

554+
fn type_contains_ty_vars(@t ty) -> bool {
555+
state obj checker(@mutable bool has_vars) {
556+
fn fold_simple_ty(@t ty) -> @t {
557+
alt (ty.struct) {
558+
case (ty_var(_)) {
559+
*has_vars = true;
560+
}
561+
case (_) {}
562+
}
563+
ret ty;
564+
}
565+
}
566+
567+
let @mutable bool b = @mutable false;
568+
fold_ty(checker(b), ty);
569+
ret *b;
570+
}
571+
554572
// Type accessors for substructures of types
555573

556574
fn ty_fn_args(@t fty) -> vec[arg] {
@@ -1197,7 +1215,21 @@ fn unify(@ty.t expected, @ty.t actual, &unify_handler handler)
11971215
auto eqer = eq_int;
11981216
auto bindings = map.mk_hashmap[int,@ty.t](hasher, eqer);
11991217

1200-
ret unify_step(bindings, expected, actual, handler);
1218+
auto ures = unify_step(bindings, expected, actual, handler);
1219+
while (true) {
1220+
alt (ures) {
1221+
case (ures_ok(?t)) {
1222+
if (!type_contains_ty_vars(t)) {
1223+
ret ures;
1224+
}
1225+
ures = unify_step(bindings, t, actual, handler);
1226+
}
1227+
case (_) {
1228+
ret ures;
1229+
}
1230+
}
1231+
}
1232+
fail;
12011233
}
12021234

12031235
fn type_err_to_str(&ty.type_err err) -> str {

0 commit comments

Comments
 (0)