소스 검색

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

Simon Krajewski 12 년 전
부모
커밋
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
 					| _ ->