@@ -472,6 +472,7 @@ let check_stmt (cx:Semant.ctxt) : (fn_ctx -> Ast.stmt -> unit) =
472
472
and internal_check_outer_lval
473
473
~mut :(mut :Ast.mutability )
474
474
~deref :(deref :bool )
475
+ ~fn_args :(fn_args :(Ast.ty array) option )
475
476
(infer :Ast.ty option )
476
477
(lval :Ast.lval )
477
478
: (Ast.ty * int) =
@@ -485,11 +486,15 @@ let check_stmt (cx:Semant.ctxt) : (fn_ctx -> Ast.stmt -> unit) =
485
486
demand expected actual;
486
487
yield_ty actual
487
488
| None , (LTYPE_poly _ as lty ) ->
488
- Common. err
489
- None
490
- " not enough context to automatically instantiate the polymorphic \
491
- type '%a'; supply type parameters explicitly"
492
- sprintf_ltype lty
489
+ begin
490
+ match fn_args with
491
+ None ->
492
+ Common. err None
493
+ " can't auto-instantiate %a" sprintf_ltype lty
494
+ | Some args ->
495
+ Common. err None " can't auto-instantiate %a on %d args"
496
+ sprintf_ltype lty (Array. length args)
497
+ end
493
498
| Some _ , (LTYPE_poly _ ) ->
494
499
(* FIXME: auto-instantiate *)
495
500
Common. unimpl
@@ -502,6 +507,7 @@ let check_stmt (cx:Semant.ctxt) : (fn_ctx -> Ast.stmt -> unit) =
502
507
and generic_check_lval
503
508
~mut :(mut :Ast.mutability )
504
509
~deref :(deref :bool )
510
+ ~fn_args :(fn_args :(Ast.ty array) option )
505
511
(infer :Ast.ty option )
506
512
(lval :Ast.lval )
507
513
: Ast.ty =
@@ -521,7 +527,7 @@ let check_stmt (cx:Semant.ctxt) : (fn_ctx -> Ast.stmt -> unit) =
521
527
| Some t -> Fmt. fmt_to_str Ast. fmt_ty t))
522
528
in
523
529
let (lval_ty, n_boxes) =
524
- internal_check_outer_lval ~mut: mut ~deref: deref infer lval
530
+ internal_check_outer_lval ~mut ~deref ~fn_args infer lval
525
531
in
526
532
let _ =
527
533
iflog cx
@@ -563,9 +569,10 @@ let check_stmt (cx:Semant.ctxt) : (fn_ctx -> Ast.stmt -> unit) =
563
569
and check_lval
564
570
?mut :(mut = Ast. MUT_immutable )
565
571
?deref:(deref= false )
572
+ ?fn_args:(fn_args= None )
566
573
(lval:Ast.lval )
567
574
: Ast. ty =
568
- generic_check_lval ~mut: mut ~deref: deref None lval
575
+ generic_check_lval ~fn_args ~ mut ~ deref None lval
569
576
570
577
and check_atom ?deref :(deref = false ) (atom:Ast.atom ) : Ast. ty =
571
578
match atom with
@@ -582,7 +589,7 @@ let check_stmt (cx:Semant.ctxt) : (fn_ctx -> Ast.stmt -> unit) =
582
589
(ty:Ast.ty )
583
590
(lval:Ast.lval )
584
591
: unit =
585
- ignore (generic_check_lval ? mut:mut ~deref: false
592
+ ignore (generic_check_lval ~ mut ~deref: false ~fn_args: None
586
593
(Some (Ast. TY_mutable ty)) lval)
587
594
in
588
595
@@ -636,7 +643,7 @@ let check_stmt (cx:Semant.ctxt) : (fn_ctx -> Ast.stmt -> unit) =
636
643
* returns the return type. *)
637
644
let check_fn (callee :Ast.lval ) (args :Ast.atom array ) : Ast.ty =
638
645
let arg_tys = Array. map check_atom args in
639
- let callee_ty = check_lval callee in
646
+ let callee_ty = check_lval callee ~fn_args: ( Some arg_tys) in
640
647
demand_fn (Array. map (fun ty -> Some ty) arg_tys) callee_ty
641
648
in
642
649
0 commit comments