aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Walton <[email protected]>2010-07-20 17:28:29 -0700
committerPatrick Walton <[email protected]>2010-07-20 17:29:36 -0700
commit34016d323c4268de5f34301021627f4a23ddd20e (patch)
tree5e826f44c8280758d4bc364b5a12d44af84b50c3
parentFixed Windows build. (diff)
downloadrust-34016d323c4268de5f34301021627f4a23ddd20e.tar.xz
rust-34016d323c4268de5f34301021627f4a23ddd20e.zip
Make bound functions have the right types
-rw-r--r--src/boot/me/type.ml22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/boot/me/type.ml b/src/boot/me/type.ml
index 005db095..e4eb98a2 100644
--- a/src/boot/me/type.ml
+++ b/src/boot/me/type.ml
@@ -719,9 +719,29 @@ let check_stmt (cx:Semant.ctxt) : (fn_ctx -> Ast.stmt -> unit) =
None -> None
| Some arg -> Some (check_atom arg)
in
+ let rec replace_args ty =
+ match ty with
+ Ast.TY_fn (ty_sig, ty_fn_aux) ->
+ let orig_slots = ty_sig.Ast.sig_input_slots in
+ let take_arg i =
+ match args.(i) with
+ None -> Some orig_slots.(i)
+ | Some _ -> None
+ in
+ let new_slots = Array.init (Array.length args) take_arg in
+ let new_slots = Common.arr_filter_some new_slots in
+ let ty_sig =
+ { ty_sig with Ast.sig_input_slots = new_slots }
+ in
+ Ast.TY_fn (ty_sig, ty_fn_aux)
+ | Ast.TY_mutable ty' -> Ast.TY_mutable (replace_args ty')
+ | Ast.TY_constrained (ty', constrs) ->
+ Ast.TY_constrained (replace_args ty', constrs)
+ | _ -> Common.bug () "replace_args: unexpected type"
+ in
let callee_ty = check_lval callee in
ignore (demand_fn (Array.map check_arg args) callee_ty);
- infer_lval callee_ty bound
+ infer_lval (replace_args callee_ty) bound
| Ast.STMT_recv (dst, src) ->
infer_lval (demand_port (check_lval src)) dst