diff --git a/src/compiler/compiler.ml b/src/compiler/compiler.ml index e3c432e93dd..698b6de8f1d 100644 --- a/src/compiler/compiler.ml +++ b/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 | _ -> diff --git a/tests/misc/projects/Issue11580/compile-fail.hxml b/tests/misc/projects/Issue11580/compile-fail.hxml new file mode 100644 index 00000000000..7f95b00f9f0 --- /dev/null +++ b/tests/misc/projects/Issue11580/compile-fail.hxml @@ -0,0 +1 @@ +compile-fail.hxml \ No newline at end of file diff --git a/tests/misc/projects/Issue11580/compile-mutual-1-fail.hxml b/tests/misc/projects/Issue11580/compile-mutual-1-fail.hxml new file mode 100644 index 00000000000..453f3bfc841 --- /dev/null +++ b/tests/misc/projects/Issue11580/compile-mutual-1-fail.hxml @@ -0,0 +1 @@ +compile-mutual-2-fail.hxml \ No newline at end of file diff --git a/tests/misc/projects/Issue11580/compile-mutual-2-fail.hxml b/tests/misc/projects/Issue11580/compile-mutual-2-fail.hxml new file mode 100644 index 00000000000..3d36a93283f --- /dev/null +++ b/tests/misc/projects/Issue11580/compile-mutual-2-fail.hxml @@ -0,0 +1 @@ +compile-mutual-1-fail.hxml \ No newline at end of file