+ else (
+ (* We are going to add an edge from parent -> node. To
+ * ensure we don't make a cycle, check there is no path
+ * already from node -> parent.
+ *)
+ (match exists_path node parent edges with
+ | None -> ()
+ | Some nodes ->
+ let loc = loc_of_node data in
+ failwithf "%a: dependency cycle: %s -> %s"
+ Ast.string_loc loc
+ (String.concat " -> " (List.map string_of_node nodes))
+ (string_of_node data)
+ );
+ G.add parent (node :: children) edges
+ ) in