-
Notifications
You must be signed in to change notification settings - Fork 99
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
"Corrected code doesn't round-trip" with deriving_inline #338
Comments
Thanks for the report! Time allocated to ppxlib has become a scarce ressource, however I'll do my best to investigate this issue. Sorry in advance for the dealy! |
Hey, thanks for reporting and sorry for the delay! I've just tried to reproduce the problem and am not able to reproduce it. Are you using a mix between |
Indeed, I am using |
Removing the usage of Instead of the above, second dune build and promote changes it to: type t = L1.t [@@deriving_inline leq]
let _ = fun (_ : t) -> ()
let rec (leq : t -> t -> bool) = L1.leq[@@ocaml.warning "-39"]
let _ = leq
[@@@end] Building that fails with the following diff:
That again wants to get rid of those Manually removing to type t = L1.t [@@deriving_inline leq]
let rec (leq : t -> t -> bool) = L1.leq[@@ocaml.warning "-39"]
[@@@end] finally builds successfully and doesn't print any diff. Therefore it seems to me that there's still some inconsistency, because initially The round-tripping error might be orthogonal then and due to some of that |
I have been experimenting with However I haven't managed to reproduce the issue clearly. This is probably hard to test if this is specific to dune running in watch mode. If there's interest I could try to spending more time on this. For now I just wanted to mention that there are still some issues in this area with recent versions of ppxlib (this is with 0.33). |
I'll have to get a bit more familiar with the original error but if you manage to get a reproducible example I'll happily look into it! |
Thanks a lot @NathanReb for offering to help! I added a new commit to the Vcs PR where I discuss some related If you try going through the same steps and let me know what this does for you, with a bit of luck, you might get similar errors! |
Sorry for the long wait, I was on vacation. I'll look into this shortly! |
I managed to reproduce it locally, I'll try to see what's going on! |
I tried it with the latest ppxlib and I'm getting different output from I'll look into it. |
This is due to the quoter returning different IDs in one case and the other. The lint build only generates the deriving_inline code and therefore gets different IDs than the regular builds that also run the rest of the PPX-es. I need to refresh my memory on how deriving_inline is supposed to work but it's a little odd that it's ran buy the regular builds AND the lint. I would expect it to only be ran by the lint builds so that it's not a dependency of the regular builds anymore. |
Circling back to the quoter issue, I think it can easily be solved by adding the entire set of ppx-es to the That being said, I agree this won't solve your main issue which is that you can't properly use |
You are talking about something inside the ppxlib implementation, or a change for the user to do in the dune config files?
I'm quite happy with a flag, and can justify allocating time for the testing of it if this helps down the road. Thanks a lot! |
Sorry this wasn't very clear indeed! On the branch you sent me for reproduction, the set of ppx-es in the I mostly wrote that for reference as I don't expect a lot of users would be interested in inlining code both via the lint step and regular builds and in your case, I believe the flag to disable deriving_inline so you don't have to depend on the relevant ppx at build time is what you are looking for! |
I looked briefly again at the example, and I think it is showing a transitory state. I don't exactly remember but I think I was trying to transition some ppx from the build to the lint stage, and may have paused in a state where the same ppx is mentioned in both places. Ideally, I would not want to do that. Instead, I'd have a clear separation of which ppx are used during the build, and which are used as linting dependency only, with zero overlap. Indeed, I didn't think about a use case by which one would inline code via the regular build (I don't have strong opinion, just can't think of a situation where I would need this at the moment). |
I guess it can serve as a quick and dirty way to inspect the code generated by a deriver but outside of that I can't think of a valid usecase. I'm wondering whether the lint phase should have the whole set of ppx-es (inline + build ones) or just the set of ppx-es used for deriving_inline and similar correction based transform. The driver has no particular idea that it's running in lint mode. Dune does invoke it with |
I have defined a deriver named "leq" with ppxlib, but I guess any ppxlib-based deriver would have the same issue.
First, I use it in a test file as follows:
Second, running dune's build and promote changes it to the following:
This promoted file now refuses to build by giving the following error:
Third, I discovered that removing the
let _
definitions and manually changed the file to the following:Then the round-tripping error disappears, but dune build again suggests a promotion to add the two definitions back, leading back to the second code snippet above.
Therefore I cannot get deriving_inline to a stable state, where it builds without round-trip errors and doesn't keep suggesting additional promotions.
The text was updated successfully, but these errors were encountered: