Skip to content

Commit

Permalink
detect recursive hxmls
Browse files Browse the repository at this point in the history
see #11580
  • Loading branch information
Simn committed Oct 22, 2024
1 parent bb28e8d commit 6f20d6b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/compiler/compiler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
| _ ->
Expand Down
1 change: 1 addition & 0 deletions tests/misc/projects/Issue11580/compile-fail.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
compile-fail.hxml
1 change: 1 addition & 0 deletions tests/misc/projects/Issue11580/compile-mutual-1-fail.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
compile-mutual-2-fail.hxml
1 change: 1 addition & 0 deletions tests/misc/projects/Issue11580/compile-mutual-2-fail.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
compile-mutual-1-fail.hxml

0 comments on commit 6f20d6b

Please sign in to comment.