فهرست منبع

more precise pattern error message (fixed issue #1404)

Simon Krajewski 12 سال پیش
والد
کامیت
2c1ff2dbb9
1فایلهای تغییر یافته به همراه9 افزوده شده و 0 حذف شده
  1. 9 0
      matcher.ml

+ 9 - 0
matcher.ml

@@ -363,6 +363,15 @@ let to_pattern ctx e t =
 				let ec = match follow tc with
 					| TEnum(en,pl) ->
 						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
+						(match ef.ef_type with
+							| TFun (args,_) ->
+								let msg = Printf.sprintf "Enum constructor %s.%s requires parameters %s"
+									(s_type_path en.e_path)
+									ef.ef_name
+									(String.concat ", " (List.map (fun (n,_,t) -> n ^ ":" ^ (s_type t)) args))
+								in
+								error msg p
+							| _ -> ());
 						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
 					| _ ->