Browse Source

point to the field name only on "Duplicate class field declaration" (closes #9061)

Aleksandr Kuzmenko 5 years ago
parent
commit
ae8337d953

+ 1 - 1
src/typing/typeloadFields.ml

@@ -1532,7 +1532,7 @@ let init_class ctx c p context_init herits fields =
 							| KAbstractImpl a -> "abstract",a.a_path
 							| KAbstractImpl a -> "abstract",a.a_path
 							| _ -> "class",c.cl_path
 							| _ -> "class",c.cl_path
 						in
 						in
-						display_error ctx ("Duplicate " ^ type_kind ^ " field declaration : " ^ s_type_path path ^ "." ^ cf.cf_name) p
+						display_error ctx ("Duplicate " ^ type_kind ^ " field declaration : " ^ s_type_path path ^ "." ^ cf.cf_name) cf.cf_name_pos
 				else
 				else
 				if fctx.do_add then add_field c cf (fctx.is_static || fctx.is_macro && ctx.in_macro)
 				if fctx.do_add then add_field c cf (fctx.is_static || fctx.is_macro && ctx.in_macro)
 			end
 			end

+ 9 - 0
tests/misc/projects/Issue9061/Main.hx

@@ -0,0 +1,9 @@
+class Main {
+	static function main() {
+
+	}
+
+	static function main() {
+
+	}
+}

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

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

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

@@ -0,0 +1 @@
+Main.hx:6: characters 18-22 : Duplicate class field declaration : Main.main