Skip to content

Commit 5cb135e

Browse files
committed
---
yaml --- r: 3297 b: refs/heads/master c: 1a6d029 h: refs/heads/master i: 3295: 9157c73 v: v3
1 parent 18018bd commit 5cb135e

File tree

4 files changed

+24
-8
lines changed

4 files changed

+24
-8
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: efd8ff46477caa89814bd5322619707873441c55
2+
refs/heads/master: 1a6d029b075c2006f6a49c5ca4a062bc2a713cd5

trunk/src/comp/middle/ty.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2580,18 +2580,23 @@ fn type_err_to_str(&ty::type_err err) -> str {
25802580

25812581
// Converts type parameters in a type to type variables and returns the
25822582
// resulting type along with a list of type variable IDs.
2583-
fn bind_params_in_type(&ctxt cx, fn() -> int next_ty_var, t typ,
2583+
fn bind_params_in_type(&span sp, &ctxt cx, fn() -> int next_ty_var, t typ,
25842584
uint ty_param_count) -> tup(vec[int], t) {
25852585
let vec[int] param_var_ids = [];
25862586
auto i = 0u;
25872587
while (i < ty_param_count) { param_var_ids += [next_ty_var()]; i += 1u; }
2588-
fn binder(ctxt cx, vec[int] param_var_ids, fn() -> int next_ty_var,
2589-
uint index) -> t {
2590-
ret mk_var(cx, param_var_ids.(index));
2588+
fn binder(span sp, ctxt cx, vec[int] param_var_ids,
2589+
fn() -> int next_ty_var, uint index) -> t {
2590+
if (index < vec::len(param_var_ids)) {
2591+
ret mk_var(cx, param_var_ids.(index));
2592+
}
2593+
else {
2594+
cx.sess.span_fatal(sp, "Unbound type parameter in callee's type");
2595+
}
25912596
}
25922597
auto new_typ =
2593-
fold_ty(cx, fm_param(bind binder(cx, param_var_ids, next_ty_var, _)),
2594-
typ);
2598+
fold_ty(cx, fm_param(bind binder(sp, cx, param_var_ids,
2599+
next_ty_var, _)), typ);
25952600
ret tup(param_var_ids, new_typ);
25962601
}
25972602

trunk/src/comp/middle/typeck.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ fn instantiate_path(&@fn_ctxt fcx, &ast::path pth, &ty_param_count_and_ty tpt,
132132
&span sp) -> ty_param_substs_opt_and_ty {
133133
auto ty_param_count = tpt._0;
134134
auto bind_result =
135-
bind_params_in_type(fcx.ccx.tcx, bind next_ty_var_id(fcx), tpt._1,
135+
bind_params_in_type(sp, fcx.ccx.tcx, bind next_ty_var_id(fcx), tpt._1,
136136
ty_param_count);
137137
auto ty_param_vars = bind_result._0;
138138
auto t = bind_result._1;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// error-pattern:Unbound type parameter in callee
2+
/* I'm actually not sure whether this should compile.
3+
But having a nice error message seems better than
4+
a bounds check failure (which is what was happening
5+
before.) */
6+
fn hd[U](&vec[U] v) -> U {
7+
fn hd1(&vec[U] w) -> U {
8+
ret w.(0);
9+
}
10+
ret hd1(v);
11+
}

0 commit comments

Comments
 (0)