2
0
Эх сурвалжийг харах

give proper error messages for uppper case patterns when expected type is enum (fixed issue #1359)

Simon Krajewski 12 жил өмнө
parent
commit
b6b8ad072c
1 өөрчлөгдсөн 1 нэмэгдсэн , 1 устгасан
  1. 1 1
      matcher.ml

+ 1 - 1
matcher.ml

@@ -344,7 +344,7 @@ let to_pattern ctx e t =
 				let tc = monomorphs ctx.type_params (t) in
 				let ec = match tc with
 					| TEnum(en,pl) ->
-						let ef = PMap.find s en.e_constrs in
+						let ef = try PMap.find s en.e_constrs with Not_found when not (is_lower_ident s) -> error ("Expected constructor for enum " ^ (s_type_path en.e_path)) p in
 						let et = mk (TTypeExpr (TEnumDecl en)) (TAnon { a_fields = PMap.empty; a_status = ref (EnumStatics en) }) p in
 						mk (TField (et,FEnum (en,ef))) (apply_params en.e_types pl ef.ef_type) p
 					| _ ->