aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPatrick Walton <[email protected]>2010-08-25 18:36:49 -0700
committerPatrick Walton <[email protected]>2010-08-25 18:36:49 -0700
commit09417f81aa86a13f64db260a2b52b2f6112e2498 (patch)
tree4a93d30cb91d57212be19aa327a2e2d98665dbe7 /src
parentActually switch to using the bigger hashmap once a it finishes growing and re... (diff)
downloadrust-09417f81aa86a13f64db260a2b52b2f6112e2498.tar.xz
rust-09417f81aa86a13f64db260a2b52b2f6112e2498.zip
Typecheck function patterns
Diffstat (limited to 'src')
-rw-r--r--src/boot/me/type.ml23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/boot/me/type.ml b/src/boot/me/type.ml
index 046b17ea..acbd30bc 100644
--- a/src/boot/me/type.ml
+++ b/src/boot/me/type.ml
@@ -264,11 +264,12 @@ let check_stmt (cx:Semant.ctxt) : (fn_ctx -> Ast.stmt -> unit) =
Hashtbl.replace cx.Semant.ctxt_all_defns defn_id
(Semant.DEFN_slot new_slot);
inferred
+ | TYPAT_fn arg_tys, Some actual ->
+ ignore (demand_fn (Array.map (fun ty -> Some ty) arg_tys) actual);
+ actual
| TYPAT_wild, Some actual -> actual
- | TYPAT_wild, None ->
+ | TYPAT_fn _, None | TYPAT_wild, None ->
Common.err None "can't infer any type for this slot"
- | TYPAT_fn _, _ ->
- Common.unimpl None "sorry, fn type patterns aren't implemented"
in
let internal_check_mod_item_decl
@@ -493,11 +494,9 @@ let check_stmt (cx:Semant.ctxt) : (fn_ctx -> Ast.stmt -> unit) =
| TYPAT_ty expected, LTYPE_mono actual ->
demand expected actual;
yield_ty actual
- | TYPAT_fn _, LTYPE_mono _ ->
- (* FIXME: typecheck *)
- Common.unimpl
- None
- "sorry, function type patterns aren't typechecked yet"
+ | TYPAT_fn arg_tys, LTYPE_mono actual ->
+ ignore (demand_fn (Array.map (fun ty -> Some ty) arg_tys) actual);
+ yield_ty actual
| TYPAT_wild, (LTYPE_poly _ as lty) ->
Common.err
None
@@ -661,7 +660,13 @@ let check_stmt (cx:Semant.ctxt) : (fn_ctx -> Ast.stmt -> unit) =
* returns the return type. *)
let check_fn (callee:Ast.lval) (args:Ast.atom array) : Ast.ty =
let arg_tys = Array.map check_atom args in
- let callee_ty = check_lval callee in
+ let callee_ty =
+ generic_check_lval
+ ~mut:Ast.MUT_immutable
+ ~deref:false
+ (TYPAT_fn arg_tys)
+ callee
+ in
demand_fn (Array.map (fun ty -> Some ty) arg_tys) callee_ty
in