aboutsummaryrefslogtreecommitdiff
path: root/src/boot
diff options
context:
space:
mode:
authorPatrick Walton <[email protected]>2010-10-27 15:02:52 -0700
committerPatrick Walton <[email protected]>2010-10-27 15:06:19 -0700
commit679dca854167cf3004f5d9f3d8a2e81921e5e2cc (patch)
tree368334f1b54a602ac1da2a8401cd47dd472d987e /src/boot
parentrustboot: Emit an error message instead of asserting on a type-param mismatch... (diff)
downloadrust-679dca854167cf3004f5d9f3d8a2e81921e5e2cc.tar.xz
rust-679dca854167cf3004f5d9f3d8a2e81921e5e2cc.zip
Emit a sensible error message if one or more of the parameters isn't enough context to instantiate a polymorphic function
Diffstat (limited to 'src/boot')
-rw-r--r--src/boot/me/type.ml13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/boot/me/type.ml b/src/boot/me/type.ml
index d22e0b05..2ff5e128 100644
--- a/src/boot/me/type.ml
+++ b/src/boot/me/type.ml
@@ -673,14 +673,19 @@ let check_stmt (cx:Semant.ctxt) : (fn_ctx -> Ast.stmt -> unit) =
in
let arg_ty_opts = Array.map (fun ty -> Some ty) arg_tys in
ignore (demand_fn ~param_handler:param_handler arg_ty_opts ty);
- let get_subst subst_opt =
+ let get_subst i subst_opt =
match subst_opt with
Some subst -> subst
| None ->
- Common.bug ()
- "internal_check_outer_lval: subst not found"
+ Common.err
+ None
+ "not enough context to instantiate parameter %d of the \
+ function with type '%a'; please supply type parameters \
+ explicitly"
+ (i + 1)
+ sprintf_ltype lty
in
- let substs = Array.map get_subst substs in
+ let substs = Array.mapi get_subst substs in
begin
match beta_reduce (Semant.lval_base_id lval) lty substs with
LTYPE_mono ty -> yield_ty ty