Identifier lookup fails to lookup functors and warns - #1471
Conversation
|
This is probably better off as a test case in test/xref2 - there's quite a lot more lightweight than the generator tests. |
bb7e050 to
7e4e418
Compare
|
@jonludlam Ah yes, I wasn't aware of these. That's much better since now the output is captured in the test and not just printed in the terminal as a side-effect of generating the outputs. |
2551d3e to
a43a58e
Compare
a43a58e to
7aa5f73
Compare
|
@jonludlam I've extended |
|
Nice! One minor comment though. I think while it's possible to do |
|
The reason I found this issue is due to the fact that I am working on code that desugars into (thus excuse the autogenerated names): module Make (T : sig type t end) : sig type included end
module INCLUDE_11 : module type of Make
module BODY_8 : sig type t end
include module type of BODY_8
module APPLY_35 : module type of struct include INCLUDE_11(BODY_8) end
include module type of APPLY_35This seems to compile using both OCaml 5.4.1 and OxCaml hence I assume that the |
|
I don't think it's needed there, no - in your example the |
|
Ah yes, you're right. We're talking about the I've pushed a commit to exclude |
|
Hmm, it's occurred to me that we've already got the functionality of let rec handle_apply env func_path arg_path m =
expansion_of_module env m
|> map_error (fun e -> (e :> simple_module_type_expr_of_module_error))
>>= function
| Signature _ | Functor (Unit, _) -> Error `ApplyNotFunctor
| Functor (Named arg, result) ->
let new_module = { m with Component.Module.type_ = ModuleType result } in
let substitution = `Substituted arg_path in
let path = `Apply (func_path, arg_path) in
let subst =
Subst.add_module
(arg.id :> Ident.module_)
(`Resolved substitution) substitution Subst.identity
in
let subst = Subst.unresolve_opaque_paths subst in
Ok (path, Subst.module_ subst new_module)
The return type of
In order to make this work I also ended up removing the unused error |
0be2d49 to
e666fcc
Compare
e666fcc to
92b8931
Compare
|
I was discarding the return code because that was the precedent in the function but it is of course nicer not to. I've applied your suggestions. That overall ended deleting more code than adding (bar the test), which is always neat! |
|
Great! thanks! |
Given a module like this:
That is where the functor
Makeis not directly applied but goes through the redirection ofNamedthe xref code fails to see this and can't link it up, creating a spurious warning:So basically it is missing that
Namedis actually referring to a functor.