Nicolas Cannasse 12 лет назад
Родитель
Сommit
f1c298a942
1 измененных файлов с 3 добавлено и 1 удалено
  1. 3 1
      typeload.ml

+ 3 - 1
typeload.ml

@@ -1085,7 +1085,9 @@ let init_class ctx c p context_init herits fields =
 				if List.mem AMacro f.cff_access then
 				if List.mem AMacro f.cff_access then
 					(match ctx.g.macros with
 					(match ctx.g.macros with
 					| Some (_,mctx) when Hashtbl.mem mctx.g.types_module c.cl_path ->
 					| Some (_,mctx) when Hashtbl.mem mctx.g.types_module c.cl_path ->
-						error "Class build macro cannot return a macro function when the class has already been compiled into the macro context" p
+						(* assume that if we had already a macro with the same name, it has not been changed during the @:build operation *)
+						if not (List.exists (fun f2 -> f2.cff_name = f.cff_name && List.mem AMacro f2.cff_access) (!fields)) then
+							error "Class build macro cannot return a macro function when the class has already been compiled into the macro context" p
 					| _ -> ())
 					| _ -> ())
 			) f;
 			) f;
 			fields := f
 			fields := f