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

Enum names clashing with internal OCaml types #156

Open
jeffa5 opened this issue Dec 10, 2020 · 0 comments
Open

Enum names clashing with internal OCaml types #156

jeffa5 opened this issue Dec 10, 2020 · 0 comments

Comments

@jeffa5
Copy link

jeffa5 commented Dec 10, 2020

With the following in test.proto:

syntax = "proto3";

message A { bool a = 0; }

message B {
  enum C { NONE = 0; }
}

message D { A a = 0; }

Running

ocaml-protoc -ocaml_all_types_ppx "deriving show" -ml_out ./ test.proto

creates some files. The test_types.ml has the following content:

[@@@ocaml.warning "-27-30-39"]


type a = {
  a : bool;
}
[@@deriving show]

type b_c =
  | None 
[@@deriving show]

type d = {
  a : a option;
}
[@@deriving show]

let rec default_a 
  ?a:((a:bool) = false)
  () : a  = {
  a;
}

let rec default_b_c () = (None:b_c)

let rec default_d 
  ?a:((a:a option) = None)
  () : d  = {
  a;
}

which fails to build:

File "test_types.ml", line 14, characters 6-14:
14 |   a : a option;
           ^^^^^^^^
Error: This variant pattern is expected to have type b_c
       The constructor Some does not belong to type b_c

(building with dune and using ocaml-protoc pinned to master)

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