소스 검색

properly display unification errors on enum fields

Simon Krajewski 12 년 전
부모
커밋
c27fc1d9bb
1개의 변경된 파일10개의 추가작업 그리고 2개의 파일을 삭제
  1. 10 2
      matcher.ml

+ 10 - 2
matcher.ml

@@ -286,7 +286,11 @@ let to_pattern ctx e t =
 				mk_con_pat (CExpr e) [] cf.cf_type p
 			| TField(_, FEnum(en,ef)) ->
 				let tc = monomorphs ctx.type_params (t) in
-				unify_enum_field en (List.map (fun _ -> mk_mono()) en.e_types) ef tc;
+				begin try
+					unify_enum_field en (List.map (fun _ -> mk_mono()) en.e_types) ef tc
+				with Unify_error l ->
+					error (error_msg (Unify l)) p
+				end;
 				mk_con_pat (CEnum(en,ef)) [] t p
 			| _ -> error "Constant expression expected" p)
 		| ECall(ec,el) ->
@@ -350,7 +354,11 @@ let to_pattern ctx e t =
 				in
 				(match ec.eexpr with
 					| TField (_,FEnum (en,ef)) ->
-						unify_enum_field en (List.map (fun _ -> mk_mono()) en.e_types) ef tc;
+						begin try
+							unify_enum_field en (List.map (fun _ -> mk_mono()) en.e_types) ef tc;
+						with Unify_error l ->
+							error (error_msg (Unify l)) p
+						end;
 						mk_con_pat (CEnum(en,ef)) [] t p
                     | TConst c ->
                         unify ctx ec.etype tc p;