Skip to content

Commit 88082c9

Browse files
committed
Remove not_found callback, handle cmj not found case in a graceful way later
1 parent afceff2 commit 88082c9

File tree

3 files changed

+9
-17
lines changed

3 files changed

+9
-17
lines changed

jscomp/core/lam_compile_env.ml

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,15 @@ type _ t =
153153
| Has_env : Env.t -> bool t (* Indicate it is pure or not *)
154154

155155

156-
(* -FIXME:
157-
Here [not_found] only means cmi not found, not cmj not found *)
156+
(*
157+
FIXME:
158+
Here [not_found] only means cmi not found, not cmj not found
159+
We do need handle cases when [not_found] hit in a graceful way
160+
*)
158161
let query_and_add_if_not_exist
159162
(type u)
160163
(oid : Lam_module_ident.t)
161-
(env : u t) ~not_found ~(found: bool -> _) =
164+
(env : u t) ~(found: bool -> _) =
162165
match Lam_module_ident.Hash.find_opt cached_tbl oid with
163166
| None ->
164167
begin match oid.kind with
@@ -171,17 +174,8 @@ let query_and_add_if_not_exist
171174
->
172175
let (cmj_path, cmj_table) as cmj_info =
173176
Js_cmj_load.find_cmj_exn (Lam_module_ident.name oid ^ Literals.suffix_cmj) in
174-
( match env with
175-
| Has_env env ->
176-
begin match
177-
Ocaml_types.find_serializable_signatures_by_path oid.id env with
178-
| None -> not_found () (* actually when [not_found] in the call site, we throw... *)
179-
| Some _ ->
180-
oid +> Ml {cmj_table;cmj_path } ;
181-
found (Js_cmj_format.is_pure cmj_table)
182-
end
183-
| No_env ->
184-
found (Js_cmj_format.is_pure cmj_table))
177+
oid +> Ml {cmj_table;cmj_path } ;
178+
found (Js_cmj_format.is_pure cmj_table)
185179
| External _ ->
186180
oid +> External;
187181
(** This might be wrong, if we happen to expand an js module
@@ -247,7 +241,6 @@ let add = Lam_module_ident.Hash_set.add
247241
let is_pure_module (id : Lam_module_ident.t) =
248242
id.kind = Runtime ||
249243
query_and_add_if_not_exist id No_env
250-
~not_found:(fun _ -> false)
251244
~found:(fun x -> x)
252245

253246
let get_required_modules

jscomp/core/lam_compile_env.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ val query_external_id_info :
9898

9999
val query_and_add_if_not_exist :
100100
Lam_module_ident.t ->
101-
'a t -> not_found:(unit -> 'b) ->
101+
'a t ->
102102
found:(bool -> 'b) -> 'b
103103

104104
val is_pure_module : Lam_module_ident.t -> bool

jscomp/core/lam_stats_export.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ let get_dependent_module_effect
112112
id.kind = Runtime ||
113113
Lam_compile_env.query_and_add_if_not_exist id
114114
(Has_env meta.env )
115-
~not_found:(fun _ -> false )
116115
~found:(fun pure -> pure)
117116
) in
118117
Ext_option.map non_pure_module (fun x -> Lam_module_ident.name x)

0 commit comments

Comments
 (0)