Skip to content

Commit 3499809

Browse files
committed
Ignore self-cycles
Signed-off-by: Yuta Sato <[email protected]>
1 parent 57a1691 commit 3499809

File tree

4 files changed

+27
-3
lines changed

4 files changed

+27
-3
lines changed

jscomp/bsb_helper/bsb_helper_depfile_gen.ml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ let oc_cmi buf namespace source =
105105
106106
When ns is turned on, `B` is interprted as `Ns-B` which is a cyclic dependency,
107107
it can be errored out earlier
108+
109+
#5368: It turns out there are many false positives on detecting self-cycles (see: `jscomp/build_tests/zerocycle`)
110+
To properly solve this, we would need to `jscomp/ml/depend.ml` because
111+
cmi and cmj is broken in the first place (same problem as in ocaml/ocaml#4618).
112+
So we will just ignore the self-cycles. Even if there is indeed a self-cycle, it should fail to compile anyway.
108113
*)
109114
let oc_deps (ast_file : string) (is_dev : bool) (db : Bsb_db_decode.t)
110115
(namespace : string option) (buf : Ext_buffer.t) (kind : [ `impl | `intf ])
@@ -133,9 +138,11 @@ let oc_deps (ast_file : string) (is_dev : bool) (db : Bsb_db_decode.t)
133138
while !offset < size do
134139
let next_tab = String.index_from s !offset magic_sep_char in
135140
let dependent_module = String.sub s !offset (next_tab - !offset) in
136-
if dependent_module = cur_module_name then (
137-
prerr_endline ("FAILED: " ^ cur_module_name ^ " has a self cycle");
138-
exit 2);
141+
if dependent_module = cur_module_name then
142+
(*prerr_endline ("FAILED: " ^ cur_module_name ^ " has a self cycle");
143+
exit 2*)
144+
(* #5368 ignore self dependencies *) ()
145+
else
139146
(match Bsb_db_decode.find db dependent_module is_dev with
140147
| None -> ()
141148
| Some { dir_name; case } ->
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// one-file false positive
2+
3+
module Nested = {
4+
module Bar = {
5+
type t = private int
6+
}
7+
}
8+
9+
open Nested
10+
11+
module Bar = {
12+
open Bar
13+
let t : t = Obj.magic(42)
14+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module Foo2 = {}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
open Demo2
2+
include Foo2

0 commit comments

Comments
 (0)