Kaynağa Gözat

bring back missing checks

Simon Krajewski 1 yıl önce
ebeveyn
işleme
6277c21bdb
2 değiştirilmiş dosya ile 15 ekleme ve 10 silme
  1. 14 10
      src/core/tUnification.ml
  2. 1 0
      src/typing/fields.ml

+ 14 - 10
src/core/tUnification.ml

@@ -918,7 +918,8 @@ and unify_anons uctx a b a1 a2 =
 		let f1 = PMap.find n a1_fields in
 		if not (unify_kind ~strict:uctx.strict_field_kind f1.cf_kind f2.cf_kind) then
 			error [invalid_kind n f1.cf_kind f2.cf_kind];
-		if (has_class_field_flag f2 CfPublic) && not (has_class_field_flag f1 CfPublic) then error [invalid_visibility n];
+		if (has_class_field_flag f2 CfPublic) && not (has_class_field_flag f1 CfPublic) then
+			error [invalid_visibility n];
 		try
 			let f1_type =
 				if fast_eq f1.cf_type f2.cf_type then f1.cf_type
@@ -926,17 +927,20 @@ and unify_anons uctx a b a1 a2 =
 			in
 			unify_with_access uctx f1 f1_type f2;
 			f1
-		with
-			Unify_error l -> error (invalid_field n :: l)
+		with Unify_error l ->
+				error (invalid_field n :: l)
 	in
 	let unify_fields a1_fields f_good f_bad =
-		PMap.iter (fun _ f2 ->
-			try
-				f_good (unify_field a1_fields f2)
-			with Not_found ->
-				if not (f_bad f2) then
-					error [has_no_field a f2.cf_name]
-		) a2.a_fields
+		try
+			PMap.iter (fun _ f2 ->
+				try
+					f_good (unify_field a1_fields f2)
+				with Not_found ->
+					if not (f_bad f2) then
+						error [has_no_field a f2.cf_name]
+			) a2.a_fields
+		with Unify_error l ->
+			error (cannot_unify a b :: l)
 	in
 	begin match !(a1.a_status),!(a2.a_status) with
 		| ClassStatics c1,ClassStatics c2 when c1 == c2 ->

+ 1 - 0
src/typing/fields.ml

@@ -333,6 +333,7 @@ let type_field cfg ctx e i p mode (with_type : WithType.t) =
 				| ClassStatics c ->
 					begin try
 						let cf = PMap.find i c.cl_statics in
+						if has_class_field_flag cf CfImpl && not (has_class_field_flag cf CfEnum) then display_error ctx.com "Cannot access non-static abstract field statically" pfield;
 						field_access cf (FHStatic c)
 					with Not_found ->
 						begin match c.cl_kind with