Simon Krajewski 9 месяцев назад
Родитель
Сommit
6f20d6b016

+ 6 - 0
src/compiler/compiler.ml

@@ -578,6 +578,7 @@ module HighLevel = struct
 		let args = !each_args @ args in
 		let added_libs = Hashtbl.create 0 in
 		let server_mode = ref SMNone in
+		let hxml_stack = ref [] in
 		let create_context args =
 			let ctx = create (server_api.on_context_create()) args in
 			ctx
@@ -637,6 +638,11 @@ module HighLevel = struct
 			| arg :: l ->
 				match List.rev (ExtString.String.nsplit arg ".") with
 				| "hxml" :: _ :: _ when (match acc with "-cmd" :: _ | "--cmd" :: _ -> false | _ -> true) ->
+					let full_path = Extc.get_full_path arg in
+					if List.mem full_path !hxml_stack then
+						raise (Arg.Bad (Printf.sprintf "Duplicate hxml inclusion: %s" full_path))
+					else
+						hxml_stack := full_path :: !hxml_stack;
 					let acc, l = (try acc, Helper.parse_hxml arg @ l with Not_found -> (arg ^ " (file not found)") :: acc, l) in
 					loop acc l
 				| _ ->

+ 1 - 0
tests/misc/projects/Issue11580/compile-fail.hxml

@@ -0,0 +1 @@
+compile-fail.hxml

+ 1 - 0
tests/misc/projects/Issue11580/compile-mutual-1-fail.hxml

@@ -0,0 +1 @@
+compile-mutual-2-fail.hxml

+ 1 - 0
tests/misc/projects/Issue11580/compile-mutual-2-fail.hxml

@@ -0,0 +1 @@
+compile-mutual-1-fail.hxml