The generated json encoder function contains an error:
let rec encode_json_a_foo (v:a_foo) =
begin match v with
| Foo_not_set -> `Assoc [("fooNotSet", `Null)]
| Bar v -> `Assoc [("bar", Pbrt_yojson.make_bool v)]
end
and encode_json_a (v:a) =
let assoc = [] in
let assoc = match v.ignored with
| None -> assoc
| Some v -> ("ignored", Pbrt_yojson.make_bool v) :: assoc
in
let assoc = match v.foo with
| Foo_not_set v -> (* Error: The constructor Foo_not_set expects 0 argument(s), but is applied here to 1 argument(s) *)
("fooNotSet", `Null) :: assoc
| Bar v ->
("bar", Pbrt_yojson.make_bool v) :: assoc
in (* match v.foo *)
`Assoc assoc
If I remove optional bool ignored from the message A, the code is generated differently and actually compiles:
let rec encode_json_a (v:a) =
begin match v with
| Foo_not_set -> `Assoc [("fooNotSet", `Null)]
| Bar v -> `Assoc [("bar", Pbrt_yojson.make_bool v)]
end
For the below protobuf snippet:
The generated json encoder function contains an error:
If I remove
optional bool ignored
from the messageA
, the code is generated differently and actually compiles: