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

Deriving fails over poly variants whose type name clashes with those in Ppx_deriving_runtime #265

Open
cemerick opened this issue Oct 31, 2022 · 0 comments

Comments

@cemerick
Copy link

This works:

type arr = [`A of int]
[@@deriving eq]

type foo = [ | arr ]
[@@deriving eq]

but this doesn't:

type array = [`A of int]
[@@deriving eq]

type foo = [ | array ]
[@@deriving eq]
8 | type foo = [ | array ]
                   ^^^^^
Error: The type array is not a variant type

Similar errors result if arr is renamed to anything defined in Ppx_deriving_runtime, e.g. list, int64, etc. Looking at the expanded output, the open! of that module is what dooms the match clause that names the poly variant (#arr here):

let rec equal_foo : foo -> foo -> Ppx_deriving_runtime.bool =
  let __0 () = equal_arr in
  ((let open! ((Ppx_deriving_runtime)[@ocaml.warning "-A"]) in
      fun lhs ->
        fun rhs ->
          match (lhs, rhs) with
          | ((#arr as lhs), (#arr as rhs)) -> ((fun x -> (__0 ()) x)) lhs rhs
          | _ -> false)

(This might be related to #254, and thus #260?)

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

No branches or pull requests

1 participant