Skip to content
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

Capture equality operator in the runtime #126

Merged
merged 2 commits into from
Aug 11, 2020
Merged

Capture equality operator in the runtime #126

merged 2 commits into from
Aug 11, 2020

Conversation

martinslota
Copy link
Contributor

I recently hit a problem with the equality operator being captured from the environment. For example, recent versions of base redefine the operator so it only accepts ints, so this code

open Base

type t = {f : int option [@default None]} [@@deriving to_yojson]

fails with something like this

File "tmp.ml", line 3, characters 0-64:
3 | type t = {f : int option [@default None]} [@@deriving to_yojson]
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: This expression has type Base.int option
       but an expression was expected of type int

It seems that the default value is needed for the failure to occur.

@kit-ty-kate
Copy link
Collaborator

Thanks a lot for bringing this issue to us. Ppx_deriving_runtime already brings with it all the standard library so re-exporting the equality function was unnecessary. I've rebased your PR by instead changing the case where the equality was used and use the proper function name re-exported by ppx_deriving.

I'm just waiting for the CI to go green and I'll merge this. Thanks a lot for your work!

@kit-ty-kate kit-ty-kate merged commit 3267547 into ocaml-ppx:master Aug 11, 2020
@martinslota martinslota deleted the capture-equality-operator-in-runtime branch August 12, 2020 07:12
kit-ty-kate added a commit to kit-ty-kate/opam-repository that referenced this pull request Nov 6, 2020
CHANGES:

  * Update to ppx_deriving 5.0 and ppxlib
    (ocaml-ppx/ppx_deriving_yojson#121)
    Rudi Grinberg, Thierry Martinez, Kate Deplaix and Gabriel Scherer

  * Fix issues when the equality operator `(=)` is shadowed
    (ocaml-ppx/ppx_deriving_yojson#126, ocaml-ppx/ppx_deriving_yojson#128, fixes ocaml-ppx/ppx_deriving_yojson#79)
    Martin Slota, Kate Deplaix
kit-ty-kate added a commit to kit-ty-kate/ppx_deriving_yojson that referenced this pull request Nov 7, 2020
kit-ty-kate added a commit that referenced this pull request Nov 7, 2020
Revert #128 and reapply the original fix from #126
kit-ty-kate added a commit to kit-ty-kate/opam-repository that referenced this pull request Nov 7, 2020
CHANGES:

  * Update to ppx_deriving 5.0 and ppxlib
    (ocaml-ppx/ppx_deriving_yojson#121)
    Rudi Grinberg, Thierry Martinez, Kate Deplaix and Gabriel Scherer

  * Fix issues when the equality operator `(=)` is shadowed
    (ocaml-ppx/ppx_deriving_yojson#126, ocaml-ppx/ppx_deriving_yojson#128, fixes ocaml-ppx/ppx_deriving_yojson#79)
    Martin Slota, Kate Deplaix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants