Thread argument-types down to internal_check_outer_lval in type.ml, in preparation for trying to infer type params from call args.
This commit is contained in:
parent
c17ea956a2
commit
6e98a3b64f
1 changed files with 16 additions and 9 deletions
|
@ -472,6 +472,7 @@ let check_stmt (cx:Semant.ctxt) : (fn_ctx -> Ast.stmt -> unit) =
|
||||||
and internal_check_outer_lval
|
and internal_check_outer_lval
|
||||||
~mut:(mut:Ast.mutability)
|
~mut:(mut:Ast.mutability)
|
||||||
~deref:(deref:bool)
|
~deref:(deref:bool)
|
||||||
|
~fn_args:(fn_args:(Ast.ty array) option)
|
||||||
(infer:Ast.ty option)
|
(infer:Ast.ty option)
|
||||||
(lval:Ast.lval)
|
(lval:Ast.lval)
|
||||||
: (Ast.ty * int) =
|
: (Ast.ty * int) =
|
||||||
|
@ -485,11 +486,15 @@ let check_stmt (cx:Semant.ctxt) : (fn_ctx -> Ast.stmt -> unit) =
|
||||||
demand expected actual;
|
demand expected actual;
|
||||||
yield_ty actual
|
yield_ty actual
|
||||||
| None, (LTYPE_poly _ as lty) ->
|
| None, (LTYPE_poly _ as lty) ->
|
||||||
Common.err
|
begin
|
||||||
None
|
match fn_args with
|
||||||
"not enough context to automatically instantiate the polymorphic \
|
None ->
|
||||||
type '%a'; supply type parameters explicitly"
|
Common.err None
|
||||||
sprintf_ltype lty
|
"can't auto-instantiate %a" sprintf_ltype lty
|
||||||
|
| Some args ->
|
||||||
|
Common.err None "can't auto-instantiate %a on %d args"
|
||||||
|
sprintf_ltype lty (Array.length args)
|
||||||
|
end
|
||||||
| Some _, (LTYPE_poly _) ->
|
| Some _, (LTYPE_poly _) ->
|
||||||
(* FIXME: auto-instantiate *)
|
(* FIXME: auto-instantiate *)
|
||||||
Common.unimpl
|
Common.unimpl
|
||||||
|
@ -502,6 +507,7 @@ let check_stmt (cx:Semant.ctxt) : (fn_ctx -> Ast.stmt -> unit) =
|
||||||
and generic_check_lval
|
and generic_check_lval
|
||||||
~mut:(mut:Ast.mutability)
|
~mut:(mut:Ast.mutability)
|
||||||
~deref:(deref:bool)
|
~deref:(deref:bool)
|
||||||
|
~fn_args:(fn_args:(Ast.ty array) option)
|
||||||
(infer:Ast.ty option)
|
(infer:Ast.ty option)
|
||||||
(lval:Ast.lval)
|
(lval:Ast.lval)
|
||||||
: Ast.ty =
|
: Ast.ty =
|
||||||
|
@ -521,7 +527,7 @@ let check_stmt (cx:Semant.ctxt) : (fn_ctx -> Ast.stmt -> unit) =
|
||||||
| Some t -> Fmt.fmt_to_str Ast.fmt_ty t))
|
| Some t -> Fmt.fmt_to_str Ast.fmt_ty t))
|
||||||
in
|
in
|
||||||
let (lval_ty, n_boxes) =
|
let (lval_ty, n_boxes) =
|
||||||
internal_check_outer_lval ~mut:mut ~deref:deref infer lval
|
internal_check_outer_lval ~mut ~deref ~fn_args infer lval
|
||||||
in
|
in
|
||||||
let _ =
|
let _ =
|
||||||
iflog cx
|
iflog cx
|
||||||
|
@ -563,9 +569,10 @@ let check_stmt (cx:Semant.ctxt) : (fn_ctx -> Ast.stmt -> unit) =
|
||||||
and check_lval
|
and check_lval
|
||||||
?mut:(mut=Ast.MUT_immutable)
|
?mut:(mut=Ast.MUT_immutable)
|
||||||
?deref:(deref=false)
|
?deref:(deref=false)
|
||||||
|
?fn_args:(fn_args=None)
|
||||||
(lval:Ast.lval)
|
(lval:Ast.lval)
|
||||||
: Ast.ty =
|
: Ast.ty =
|
||||||
generic_check_lval ~mut:mut ~deref:deref None lval
|
generic_check_lval ~fn_args ~mut ~deref None lval
|
||||||
|
|
||||||
and check_atom ?deref:(deref=false) (atom:Ast.atom) : Ast.ty =
|
and check_atom ?deref:(deref=false) (atom:Ast.atom) : Ast.ty =
|
||||||
match atom with
|
match atom with
|
||||||
|
@ -582,7 +589,7 @@ let check_stmt (cx:Semant.ctxt) : (fn_ctx -> Ast.stmt -> unit) =
|
||||||
(ty:Ast.ty)
|
(ty:Ast.ty)
|
||||||
(lval:Ast.lval)
|
(lval:Ast.lval)
|
||||||
: unit =
|
: unit =
|
||||||
ignore (generic_check_lval ?mut:mut ~deref:false
|
ignore (generic_check_lval ~mut ~deref:false ~fn_args:None
|
||||||
(Some (Ast.TY_mutable ty)) lval)
|
(Some (Ast.TY_mutable ty)) lval)
|
||||||
in
|
in
|
||||||
|
|
||||||
|
@ -636,7 +643,7 @@ let check_stmt (cx:Semant.ctxt) : (fn_ctx -> Ast.stmt -> unit) =
|
||||||
* returns the return type. *)
|
* returns the return type. *)
|
||||||
let check_fn (callee:Ast.lval) (args:Ast.atom array) : Ast.ty =
|
let check_fn (callee:Ast.lval) (args:Ast.atom array) : Ast.ty =
|
||||||
let arg_tys = Array.map check_atom args in
|
let arg_tys = Array.map check_atom args in
|
||||||
let callee_ty = check_lval callee in
|
let callee_ty = check_lval callee ~fn_args:(Some arg_tys) in
|
||||||
demand_fn (Array.map (fun ty -> Some ty) arg_tys) callee_ty
|
demand_fn (Array.map (fun ty -> Some ty) arg_tys) callee_ty
|
||||||
in
|
in
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue