Skip to content

Commit 679dca8

Browse files
committed
Emit a sensible error message if one or more of the parameters isn't enough context to instantiate a polymorphic function
1 parent b3c4c14 commit 679dca8

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/boot/me/type.ml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -673,14 +673,19 @@ let check_stmt (cx:Semant.ctxt) : (fn_ctx -> Ast.stmt -> unit) =
673673
in
674674
let arg_ty_opts = Array.map (fun ty -> Some ty) arg_tys in
675675
ignore (demand_fn ~param_handler:param_handler arg_ty_opts ty);
676-
let get_subst subst_opt =
676+
let get_subst i subst_opt =
677677
match subst_opt with
678678
Some subst -> subst
679679
| None ->
680-
Common.bug ()
681-
"internal_check_outer_lval: subst not found"
680+
Common.err
681+
None
682+
"not enough context to instantiate parameter %d of the \
683+
function with type '%a'; please supply type parameters \
684+
explicitly"
685+
(i + 1)
686+
sprintf_ltype lty
682687
in
683-
let substs = Array.map get_subst substs in
688+
let substs = Array.mapi get_subst substs in
684689
begin
685690
match beta_reduce (Semant.lval_base_id lval) lty substs with
686691
LTYPE_mono ty -> yield_ty ty

0 commit comments

Comments
 (0)