@@ -264,11 +264,12 @@ let check_stmt (cx:Semant.ctxt) : (fn_ctx -> Ast.stmt -> unit) =
264
264
Hashtbl. replace cx.Semant. ctxt_all_defns defn_id
265
265
(Semant. DEFN_slot new_slot);
266
266
inferred
267
+ | TYPAT_fn arg_tys , Some actual ->
268
+ ignore (demand_fn (Array. map (fun ty -> Some ty) arg_tys) actual);
269
+ actual
267
270
| TYPAT_wild , Some actual -> actual
268
- | TYPAT_wild , None ->
271
+ | TYPAT_fn _ , None | TYPAT_wild , None ->
269
272
Common. err None " can't infer any type for this slot"
270
- | TYPAT_fn _ , _ ->
271
- Common. unimpl None " sorry, fn type patterns aren't implemented"
272
273
in
273
274
274
275
let internal_check_mod_item_decl
@@ -493,11 +494,9 @@ let check_stmt (cx:Semant.ctxt) : (fn_ctx -> Ast.stmt -> unit) =
493
494
| TYPAT_ty expected , LTYPE_mono actual ->
494
495
demand expected actual;
495
496
yield_ty actual
496
- | TYPAT_fn _ , LTYPE_mono _ ->
497
- (* FIXME: typecheck *)
498
- Common. unimpl
499
- None
500
- " sorry, function type patterns aren't typechecked yet"
497
+ | TYPAT_fn arg_tys , LTYPE_mono actual ->
498
+ ignore (demand_fn (Array. map (fun ty -> Some ty) arg_tys) actual);
499
+ yield_ty actual
501
500
| TYPAT_wild , (LTYPE_poly _ as lty ) ->
502
501
Common. err
503
502
None
@@ -661,7 +660,13 @@ let check_stmt (cx:Semant.ctxt) : (fn_ctx -> Ast.stmt -> unit) =
661
660
* returns the return type. *)
662
661
let check_fn (callee :Ast.lval ) (args :Ast.atom array ) : Ast.ty =
663
662
let arg_tys = Array. map check_atom args in
664
- let callee_ty = check_lval callee in
663
+ let callee_ty =
664
+ generic_check_lval
665
+ ~mut: Ast. MUT_immutable
666
+ ~deref: false
667
+ (TYPAT_fn arg_tys)
668
+ callee
669
+ in
665
670
demand_fn (Array. map (fun ty -> Some ty) arg_tys) callee_ty
666
671
in
667
672
0 commit comments