Typecheck operator args bottom-up after monomorphisation

(?)
This commit is contained in:
Louis Gesbert 2024-06-24 11:56:25 +02:00
parent c0ad0e8820
commit d073103578

View File

@ -895,15 +895,17 @@ and typecheck_expr_top_down :
let args = let args =
Operator.kind_dispatch (Mark.set pos_e op) Operator.kind_dispatch (Mark.set pos_e op)
~polymorphic:(fun op -> ~polymorphic:(fun op ->
(* Type the operator first, then right-to-left: polymorphic operators if env.flags.assume_op_types then (
are required to allow the resolution of all type variables this unify ctx e (polymorphic_op_return_type ctx e op t_args) tau;
way *) List.rev_map (typecheck_expr_bottom_up ctx env) (List.rev args))
if not env.flags.assume_op_types then else (
unify ctx e (polymorphic_op_type op) t_func (* Type the operator first, then right-to-left: polymorphic
else unify ctx e (polymorphic_op_return_type ctx e op t_args) tau; operators are required to allow the resolution of all type
List.rev_map2 variables this way *)
(typecheck_expr_top_down ctx env) unify ctx e (polymorphic_op_type op) t_func;
(List.rev t_args) (List.rev args)) List.rev_map2
(typecheck_expr_top_down ctx env)
(List.rev t_args) (List.rev args)))
~overloaded:(fun op -> ~overloaded:(fun op ->
(* Typing the arguments first is required to resolve the operator *) (* Typing the arguments first is required to resolve the operator *)
let args' = List.map2 (typecheck_expr_top_down ctx env) t_args args in let args' = List.map2 (typecheck_expr_top_down ctx env) t_args args in