Explorar el Código

do not bind monomorphs during analysis

Simon Krajewski hace 9 años
padre
commit
00f951180a
Se han modificado 1 ficheros con 6 adiciones y 2 borrados
  1. 6 2
      analyzer.ml

+ 6 - 2
analyzer.ml

@@ -1810,6 +1810,10 @@ module DataFlow (M : DataFlowApi) = struct
 		M.commit ctx
 end
 
+let type_iseq_strict_no_mono t1 t2 = match follow t1,follow t2 with
+	| TMono _,_ | _,TMono _ -> true
+	| _ -> type_iseq_strict t1 t2
+
 (*
 	ConstPropagation implements sparse conditional constant propagation using the DataFlow algorithm. Its lattice consists of
 	constants and enum values, but only the former are propagated. Enum values are treated as immutable data tuples and allow
@@ -1930,7 +1934,7 @@ module ConstPropagation = DataFlow(struct
 				raise Not_found
 			| Const ct ->
 				let e' = Codegen.type_constant ctx.com (tconst_to_const ct) e.epos in
-				if not (type_iseq e'.etype e.etype) then raise Not_found;
+				if not (type_iseq_strict_no_mono e'.etype e.etype) then raise Not_found;
 				e'
 		in
 		let rec commit e = match e.eexpr with
@@ -2024,7 +2028,7 @@ module CopyPropagation = DataFlow(struct
 						raise Not_found
 					in
 					let v' = match lat with Local v -> v | _ -> leave() in
-					if not (type_iseq_strict v'.v_type v.v_type) then leave();
+					if not (type_iseq_strict_no_mono v'.v_type v.v_type) then leave();
 					let v'' = get_var_origin ctx.graph v' in
 					(* This restriction is in place due to how we currently reconstruct the AST. Multiple SSA-vars may be turned back to
 					   the same origin var, which creates interference that is not tracked in the analysis. We address this by only