Skip to content

Commit 34016d3

Browse files
committed
Make bound functions have the right types
1 parent 66181ce commit 34016d3

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/boot/me/type.ml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,9 +719,29 @@ let check_stmt (cx:Semant.ctxt) : (fn_ctx -> Ast.stmt -> unit) =
719719
None -> None
720720
| Some arg -> Some (check_atom arg)
721721
in
722+
let rec replace_args ty =
723+
match ty with
724+
Ast.TY_fn (ty_sig, ty_fn_aux) ->
725+
let orig_slots = ty_sig.Ast.sig_input_slots in
726+
let take_arg i =
727+
match args.(i) with
728+
None -> Some orig_slots.(i)
729+
| Some _ -> None
730+
in
731+
let new_slots = Array.init (Array.length args) take_arg in
732+
let new_slots = Common.arr_filter_some new_slots in
733+
let ty_sig =
734+
{ ty_sig with Ast.sig_input_slots = new_slots }
735+
in
736+
Ast.TY_fn (ty_sig, ty_fn_aux)
737+
| Ast.TY_mutable ty' -> Ast.TY_mutable (replace_args ty')
738+
| Ast.TY_constrained (ty', constrs) ->
739+
Ast.TY_constrained (replace_args ty', constrs)
740+
| _ -> Common.bug () "replace_args: unexpected type"
741+
in
722742
let callee_ty = check_lval callee in
723743
ignore (demand_fn (Array.map check_arg args) callee_ty);
724-
infer_lval callee_ty bound
744+
infer_lval (replace_args callee_ty) bound
725745

726746
| Ast.STMT_recv (dst, src) ->
727747
infer_lval (demand_port (check_lval src)) dst

0 commit comments

Comments
 (0)