Browse Source

[typer] don't bind monos when building top-down-inference matrix

Simon Krajewski 3 years ago
parent
commit
9010c38337
2 changed files with 14 additions and 1 deletions
  1. 10 0
      src/core/tFunctions.ml
  2. 4 1
      src/typing/typer.ml

+ 10 - 0
src/core/tFunctions.ml

@@ -338,6 +338,16 @@ let duplicate t =
 	in
 	in
 	loop t
 	loop t
 
 
+let dynamify_monos t =
+	let rec loop t =
+		match t with
+		| TMono { tm_type = None } ->
+			t_dynamic
+		| _ ->
+			map loop t
+	in
+	loop t
+
 exception ApplyParamsRecursion
 exception ApplyParamsRecursion
 
 
 (* substitute parameters with other types *)
 (* substitute parameters with other types *)

+ 4 - 1
src/typing/typer.ml

@@ -1220,10 +1220,13 @@ and type_local_function ctx kind f with_type p =
 				begin match follow t with
 				begin match follow t with
 				| TFun(args,ret) when List.length args = arity ->
 				| TFun(args,ret) when List.length args = arity ->
 					List.iteri (fun i (_,_,t) ->
 					List.iteri (fun i (_,_,t) ->
+						(* We don't wand to bind monomorphs because we want the widest type *)
+						let t = dynamify_monos t in
 						m#join t (i + 1);
 						m#join t (i + 1);
 					) args;
 					) args;
+					let ret = dynamify_monos ret in
 					m#join ret 0;
 					m#join ret 0;
-				| _ ->
+				| t ->
 					()
 					()
 				end;
 				end;
 				loop l
 				loop l