Selaa lähdekoodia

[hxb] writer: avoid side effects on TAnon fields type

Rudy Ges 1 vuosi sitten
vanhempi
commit
50d784997c
1 muutettua tiedostoa jossa 9 lisäystä ja 15 poistoa
  1. 9 15
      src/typing/tanon_identification.ml

+ 9 - 15
src/typing/tanon_identification.ml

@@ -1,21 +1,15 @@
 open Globals
 open Type
 
-let rec replace_mono t =
-	match t with
-	| TMono t ->
-		(match t.tm_type with
-		| None -> Monomorph.bind t t_dynamic
-		| Some _ -> ())
-	| TEnum (_,p) | TInst (_,p) | TType (_,p) | TAbstract (_,p) ->
-		List.iter replace_mono p
-	| TFun (args,ret) ->
-		List.iter (fun (_,_,t) -> replace_mono t) args;
-		replace_mono ret
-	| TAnon _
-	| TDynamic _ -> ()
-	| TLazy f ->
-		replace_mono (lazy_type f)
+let replace_mono t =
+	let rec loop t =
+		match t with
+		| TMono ({ tm_type = None } as tmono) ->
+			Monomorph.bind tmono t_dynamic
+		| _ ->
+			TFunctions.iter loop t
+	in
+	loop t
 
 type 'a path_field_mapping = {
 	pfm_path : path;