@@ -148,11 +148,11 @@ let add_lib_import msgs imported ri_ref at lib_path =
148148 | Error err ->
149149 Diag. add_msg msgs err
150150
151- let add_idl_import msgs imported ri_ref at full_path bytes =
151+ let add_idl_import msgs imported ri_ref at full_path envvar_or_bytes =
152152 if Sys. file_exists full_path
153153 then begin
154- ri_ref := IDLPath (full_path, bytes );
155- imported := RIM. add ( IDLPath (full_path, bytes)) at ! imported
154+ ri_ref := IDLPath (full_path, envvar_or_bytes );
155+ imported := RIM. add ! ri_ref at ! imported
156156 end else
157157 err_file_does_not_exist msgs at full_path
158158
@@ -188,7 +188,13 @@ let resolve_import_string msgs base actor_idl_path aliases packages imported (f,
188188 | None -> err_actor_import_without_idl_path msgs at
189189 | Some actor_base ->
190190 let full_path = in_base actor_base (Url. idl_basename_of_blob bytes) in
191- add_idl_import msgs imported ri_ref at full_path bytes
191+ add_idl_import msgs imported ri_ref at full_path (Either. Right bytes)
192+ in
193+ let resolve_env envvar = match actor_idl_path with
194+ | None -> err_actor_import_without_idl_path msgs at
195+ | Some actor_base ->
196+ let full_path = in_base actor_base envvar in
197+ add_idl_import msgs imported ri_ref at full_path (Either. Left envvar)
192198 in
193199 match Url. parse f with
194200 | Ok (Url. Relative path ) ->
@@ -210,7 +216,7 @@ let resolve_import_string msgs base actor_idl_path aliases packages imported (f,
210216 | Ok (Url. IcAlias alias ) ->
211217 begin match M. find_opt alias aliases with
212218 | Some (Either. Right bytes ) -> resolve_ic bytes
213- | Some (Either. Left envvar ) -> failwith " envvar"
219+ | Some (Either. Left envvar ) -> resolve_env envvar
214220 | None -> err_alias_not_defined msgs at alias
215221 end
216222 | Ok (Url. FileValue path ) ->
0 commit comments