Просмотр исходного кода

fixed ef_params handling (fixed issue #1584)

Simon Krajewski 12 лет назад
Родитель
Сommit
5b0450b09d
1 измененных файлов с 4 добавлено и 6 удалено
  1. 4 6
      matcher.ml

+ 4 - 6
matcher.ml

@@ -349,16 +349,14 @@ let to_pattern ctx e t =
 					| TField (_,FEnum (_,f)) -> f
 					| _ -> error ("Expected constructor for enum " ^ (s_type_path en.e_path)) p
 				in
-				let mono_map,monos,tpl = List.fold_left (fun (mm,ml,tpl) (n,t) ->
-					let mono = mk_mono() in
-					(n,mono) :: mm, mono :: ml, t :: tpl) ([],[],[]) ef.ef_params
-				in
+				let monos = List.map (fun _ -> mk_mono()) ef.ef_params in
 				let tl = match apply_params en.e_types pl (apply_params ef.ef_params monos ef.ef_type) with
 					| TFun(args,r) ->
 						unify ctx r t p;
+						List.iter2 (fun m (_,t) -> match follow m with TMono _ -> Type.unify m t | _ -> ()) monos ef.ef_params;
 						List.map (fun (n,_,t) ->
-							let tf = apply_params mono_map tpl (follow t) in
-							if is_null t then ctx.t.tnull tf else tf
+							let t = follow t in
+							if is_null t then ctx.t.tnull t else t
 						) args
 					| _ -> error "Arguments expected" p
 				in