소스 검색

better error position on `abstract new` (#10426)

Aleksandr Kuzmenko 3 년 전
부모
커밋
f5986de3c9
2개의 변경된 파일8개의 추가작업 그리고 3개의 파일을 삭제
  1. 7 2
      src/typing/typeloadFields.ml
  2. 1 1
      tests/misc/projects/Issue10426/compile-fail.hxml.stderr

+ 7 - 2
src/typing/typeloadFields.ml

@@ -1250,8 +1250,13 @@ let create_method (ctx,cctx,fctx) c f fd p =
 	if fctx.is_final then add_class_field_flag cf CfFinal;
 	if fctx.is_extern then add_class_field_flag cf CfExtern;
 	if fctx.is_abstract then begin
-		if fctx.field_kind = FKConstructor then
-			display_error ctx "Constructors cannot be abstract" p;
+		if fctx.field_kind = FKConstructor then begin
+			let p =
+				try List.assoc AAbstract f.cff_access
+				with Not_found -> p
+			in
+			display_error ctx "Constructors cannot be abstract" p
+		end;
 		add_class_field_flag cf CfAbstract;
 	end;
 	if fctx.is_abstract_member then add_class_field_flag cf CfImpl;

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

@@ -1 +1 @@
-Main.hx:6: characters 2-31 : Constructors cannot be abstract
+Main.hx:6: characters 2-10 : Constructors cannot be abstract