Repository navigation
Deprecate >> in ppx - #471
Conversation
|
Thanks for doing this! I haven't tried it out yet, but to offer a suggestion about the warnings: you may be able to disable them by tagging the test with |
|
Good idea! I tried to add some tags to the local jbuild rule to make warning 22 (deprecation) non-fatal but didn't manage to. I was trying to keep the warning but make it just that: a warning. I'll try deactivating it completely. |
|
I didn't manage to use the |
|
Indeed, I wasn't able to get it work using any form of I think the only thing missing is somewhat better locations. For example, for this file: let () =
Lwt_main.run begin
Lwt_unix.sleep 1. >>
Lwt_unix.sleep 1. >>
Lwt_unix.sleep 1.
endthe output is Speculating, but I think the location is the whole file or so :) |
| [%expr Lwt.bind [%e lhs] (fun [%p pat] -> [%e rhs])] | ||
| [%expr (Lwt.bind [%e lhs] (fun [%p pat] -> [%e rhs])) | ||
| [@ocaml.ppwarning "The operator >> is deprecated"] | ||
| ] |
There was a problem hiding this comment.
You don't provide any location for the attribute here. The location is important, since it's used in the error message. You should build up the attribute by hand using attribute_of_warning, it makes things simpler.
|
About localized disabling of warning 22 ... I think it should work on trunk. @Octachron might be able to tell more. |
|
I can confirm that disabling locally preprocessor warnings works on trunk. |
|
That's good, thanks. We'll have to use the warning options, though, because we are testing on versions down to 4.02. |
|
So I'm struggling a bit with using the Where can I find documentation? I manage to get something using the |
|
My go-to documentation for metaquot was always the comment in its source code: Let us know if you're still blocked on the other issue. Maybe you the easiest way to solve it will be to use |
|
I finally understand (at least I think I do!) the interaction of With this final push, the location is still not great (it covers the whole expression, including rhs and lhs terms around the deprecated operator), but it's better than the previous attempts I made. Possible improvements:
|
|
Fixed the warning 22 issue mentioned above: |
| )) | ||
|
|
||
| | [%expr [%e? lhs] >> [%e? rhs]] -> | ||
| | [%expr [%e? lhs] >> [%e? rhs]] as e -> |
There was a problem hiding this comment.
To get the location of the >>, I believe you can either:
- Change this pattern to manually match on
Pexp_applyofPexp_ident ">>"(I'm skipping the wrapping location and attributes and structures around eachPexp_*). You should then be able to get the location from thePexp_ident. - Leave this pattern as is, because it's pretty legible. In the case body below, match again on
Pexp_apply(whateis) and extract the location of the function (it should be aPexp_ident ">>"wrapped in location information).
I don't recall immediately how binary operator application is represented, it's likely that there are actually two Pexp_applys, one nested in the other.
|
For the warning number, I think 22 is fine. We could contrive some crazy scheme to get warning 3, where we introduce a dummy local deprecated value in a local module, just so we can refer to it in the generated code and trigger warning 3. But I doubt the complexity is necessary. |
|
Thanks for the suggestion. I went for option 2: rematch I wonder if ppx_tools' metaquot can do that directly. Does it have alias patterns where you give both a literal pattern and a name? |
|
Not that I'm aware of. It may be possible to get that effect for some sub-patterns, but off the top of my head, I'm not aware of a nice way to do it for the operation in this particular one. |
|
Maybe you can do some kind of |
|
It looks ready for merge to me. Let me know if/when not going to edit the The warning doesn't seem picked up by Merlin, but that's okay. |
Actually, that's weird, there is no reason that should happen. |
It's possible my Merlin setup is broken somehow, the editor often doesn't trigger Merlin, etc. However, Merlin was working for other warnings and errors in other expressions in the same session. I'd be interested in the result if you tried it.. |
|
In Can anyone with more knowledge of how Merlin's config works comment? |
|
@raphael-proust That |
|
Did you also observe that Merlin doesn't highlight the error? BTW I don't think that blocks the PR from my point of view, but I'm also fine with waiting if you'd like to look into this :) |
|
On my machine, the error is also not highlighted by Merlin. You can merge the PR (with squashing would be better I think). |
|
Thanks @raphael-proust and @Drup! |
This PR is for issue: #387
It adds a warning to generated code that uses
>>from ppx.Note that, in its current form, the PR removes tests for
>>altogether. These tests fails because of-w @ain the flags which turn all warning into errors. Comments and suggestions on this are welcome.EDIT by @aantron: resolves #387.