mransan/ocaml-protoc

Crash compiling Yojson use of empty messages

Closed this issue ยท 3 comments

Hi! Thank you for your work. ๐Ÿ˜„ When compiling the use of an empty message, i.e.:

message Empty {}  // This line is fine
message Test {
  Empty empty = 1;  // This crashes
}

โ€ฆI get a crash in Yojson mode:

$ ocaml-protoc -binary -yojson -ml_out . test.proto
Generating ./test_types.mli
Generating ./test_types.ml
File "src/compilerlib/pb_codegen_decode_yojson.ml", line 31, characters 18-24: Assertion failed

Indeed, that's https://github.com/mransan/ocaml-protoc/blob/master/src/compilerlib/pb_codegen_decode_yojson.ml#L31

I know that the JSON representation should be an empty object (i.e. `Assoc []) but not to the point of knowing how to contribute this. ๐Ÿ˜•

Lupus commented

message Empty {} also seems to omit the type from generated files with types, so support for empty protobuf messages is not really present in the library...

Lupus commented

I believe #198 should address this issue.