Skip to content

Commit 990aa2b

Browse files
committed
---
yaml --- r: 1194 b: refs/heads/master c: b7d2fe5 h: refs/heads/master v: v3
1 parent c03761f commit 990aa2b

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
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: 116dd9e33803cb3b4a4c87a181ec3bd5d9966f63
2+
refs/heads/master: b7d2fe57cfa7d260838832ad8c301a946206c16d

trunk/src/comp/middle/ty.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ type unify_handler = obj {
5151
fn record_local(ast.def_id id, @t ty);
5252
fn unify_expected_param(ast.def_id id, @t expected, @t actual)
5353
-> unify_result;
54+
fn unify_actual_param(ast.def_id id, @t expected, @t actual)
55+
-> unify_result;
5456
};
5557

5658
tag type_err {
@@ -854,9 +856,9 @@ fn unify(@ty.t expected, @ty.t actual, &unify_handler handler)
854856
// TODO: rewrite this using tuple pattern matching when available, to
855857
// avoid all this rightward drift and spikiness.
856858

857-
// If the RHS is a variable type, then just do the appropriate
858-
// binding.
859859
alt (actual.struct) {
860+
// If the RHS is a variable type, then just do the appropriate
861+
// binding.
860862
case (ty.ty_var(?actual_id)) {
861863
alt (bindings.find(actual_id)) {
862864
case (some[@ty.t](?actual_ty)) {
@@ -885,6 +887,9 @@ fn unify(@ty.t expected, @ty.t actual, &unify_handler handler)
885887
}
886888
ret result;
887889
}
890+
case (ty.ty_param(?actual_id)) {
891+
ret handler.unify_actual_param(actual_id, expected, actual);
892+
}
888893
case (_) { /* empty */ }
889894
}
890895

@@ -1131,8 +1136,7 @@ fn unify(@ty.t expected, @ty.t actual, &unify_handler handler)
11311136
}
11321137

11331138
case (ty.ty_param(?expected_id)) {
1134-
ret handler.unify_expected_param(expected_id,
1135-
expected,
1139+
ret handler.unify_expected_param(expected_id, expected,
11361140
actual);
11371141
}
11381142
}

trunk/src/comp/middle/typeck.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,18 @@ fn unify(&@fn_ctxt fcx, @ty.t expected, @ty.t actual) -> ty.unify_result {
509509
}
510510
ret ty.ures_err(ty.terr_mismatch, expected, actual);
511511
}
512+
fn unify_actual_param(ast.def_id id, @ty.t expected, @ty.t actual)
513+
-> ty.unify_result {
514+
alt (expected.struct) {
515+
case (ty.ty_param(?expected_id)) {
516+
if (id._0 == expected_id._0 && id._1 == expected_id._1) {
517+
ret ty.ures_ok(actual);
518+
}
519+
}
520+
case (_) { /* fall through */ }
521+
}
522+
ret ty.ures_err(ty.terr_mismatch, expected, actual);
523+
}
512524
}
513525

514526
auto handler = unify_handler(fcx);

0 commit comments

Comments
 (0)