2
0
Эх сурвалжийг харах

don't allow to define a static with same name as a super member (fixed issue #1287)

Nicolas Cannasse 12 жил өмнө
parent
commit
edfaa71823
1 өөрчлөгдсөн 2 нэмэгдсэн , 1 устгасан
  1. 2 1
      typeload.ml

+ 2 - 1
typeload.ml

@@ -1388,7 +1388,8 @@ let init_class ctx c p context_init herits fields =
 				c.cl_constructor <- Some f;
 			end else if not is_static || f.cf_name <> "__init__" then begin
 				if PMap.mem f.cf_name (if is_static then c.cl_statics else c.cl_fields) then error ("Duplicate class field declaration : " ^ f.cf_name) p;
-				if PMap.exists f.cf_name (if is_static then c.cl_fields else c.cl_statics) then error ("Same field name can't be use for both static and instance : " ^ f.cf_name) p;
+				let dup = if is_static then PMap.exists f.cf_name c.cl_fields || has_field f.cf_name c.cl_super else PMap.exists f.cf_name c.cl_statics in
+				if dup then error ("Same field name can't be use for both static and instance : " ^ f.cf_name) p;
 				if is_static then begin
 					c.cl_statics <- PMap.add f.cf_name f c.cl_statics;
 					c.cl_ordered_statics <- f :: c.cl_ordered_statics;