소스 검색

[typer] fix abstract impl being printed in "duplicate field" errors

closes #8258
Jens Fischer 6 년 전
부모
커밋
866f5b2d22

+ 5 - 1
src/typing/typeloadFields.ml

@@ -1472,7 +1472,11 @@ let init_class ctx c p context_init herits fields =
 						(if not (Meta.has Meta.Overload mainf.cf_meta) then display_error ctx ("Overloaded methods must have @:overload metadata") mainf.cf_pos);
 						mainf.cf_overloads <- cf :: mainf.cf_overloads
 					else
-						display_error ctx ("Duplicate class field declaration : " ^ s_type_path c.cl_path ^ "." ^ cf.cf_name) p
+						let type_kind,path = match c.cl_kind with
+							| KAbstractImpl a -> "abstract",a.a_path
+							| _ -> "class",c.cl_path
+						in
+						display_error ctx ("Duplicate " ^ type_kind ^ " field declaration : " ^ s_type_path path ^ "." ^ cf.cf_name) p
 				else
 				if fctx.do_add then add_field c cf (fctx.is_static || fctx.is_macro && ctx.in_macro)
 			end

+ 5 - 0
tests/misc/projects/Issue8258/Main.hx

@@ -0,0 +1,5 @@
+enum abstract Foobar(String) {
+	var A = "x";
+	var B = "y";
+	var A = "z";
+}

+ 1 - 0
tests/misc/projects/Issue8258/compile-fail.hxml

@@ -0,0 +1 @@
+-main Main

+ 1 - 0
tests/misc/projects/Issue8258/compile-fail.hxml.stderr

@@ -0,0 +1 @@
+Main.hx:4: characters 2-14 : Duplicate abstract field declaration : Foobar.A