Browse Source

prevent a built class already in macro context to have macros (fixed issue #1227)

Nicolas Cannasse 12 years ago
parent
commit
34f9b1ce46
1 changed files with 9 additions and 1 deletions
  1. 9 1
      typeload.ml

+ 9 - 1
typeload.ml

@@ -1080,7 +1080,15 @@ let init_class ctx c p context_init herits fields =
 	let get_fields() = !fields in
 	build_module_def ctx (TClassDecl c) c.cl_meta get_fields context_init (fun (e,p) ->
 		match e with
-		| EVars [_,Some (CTAnonymous f),None] -> fields := f
+		| EVars [_,Some (CTAnonymous f),None] ->
+			List.iter (fun f ->
+				if List.mem AMacro f.cff_access then
+					(match ctx.g.macros with
+					| 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
+					| _ -> ())
+			) f;
+			fields := f
 		| _ -> error "Class build macro must return a single variable with anonymous fields" p
 	);
 	let fields = !fields in