Skip to content

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

@cemerick

Description

@cemerick

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?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions