-
Notifications
You must be signed in to change notification settings - Fork 396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ppx_import + ppxlib based deriver applied in the "wrong" order #1861
Comments
Indeed maybe this is not working well with |
I just tried with another |
Normally it should work because ppxlib integrates itself with the omp driver. This is all horribly complicated but it's supposed to work. It is definitely surprising that it works with merlin but not for normal compilation though. I'm puzzled as to what is going on. |
Hmm, one thing to consider is that ppx_import behaves differently when called from ocamldep. This is because at this stage the cmi of the other modules don't exist so it cannot call the typer. IIRC, ppx_import generates a dummy type, maybe that dummy type is something that is not understood by ppx_factory? |
I will have a look at that. In my original encounter with this issue, the type that was imported was from a separate library, would that change anything with regards to the potential issue you're describing? |
Nope. I just had a look at ppx_import.ml, and indeed when called by ocamldep it replaces |
Hmm, I guess I'm a little confused. What would be the point of using
I guess this is unrelated to |
The problem is that It appears to work with ppx_compare because To work around this, you should probably accept abstract types in ppx_factory. Or at least accept them only when called from ocamldep. |
Ok that makes much more sense now. Indeed returning an empty list of str_items appeared to solve the issue in my case. I'll figure something out to properly deal with abstract types in such cases. I feel like this might be a worthy addition to Thanks for your help on this! |
No problem! Documenting this would be nice indeed |
I recently started working on a new ppxlib based deriver: ppx_factory. As I was trying to use it conjointly with
ppx_import
I ran into an unsettling error. The error seems to indicate that the deriver is applied beforeppx_import
's rewriter somehow.I managed to reproduce it in a minimal example. Consider the following
a.ml
file:the following
b.ml
file:and finally the following
dune
file:Building the library fails with:
I double checked my code to make sure the error doesn't come from a bug in
ppx_factory
but it seems not.What disturbs me the most is that
merlin
is happy with that when I openb.ml
in my editor and autocompletion even offers me the values generated byppx_factory
.I'm not sure whether this should be reported here or in ppxlib. I may have misused
ppxlib
somehow but that strange difference betweenmerlin
anddune
made me think there was something wrong going on unrelated to my implementation.Do you have any idea what it might be?
The text was updated successfully, but these errors were encountered: