msoucy / dproto

D Protocol Buffer mixins to create structures at compile time
Boost Software License 1.0
37 stars 16 forks source link

BUG: ProtocolBufferFromString doesn't check for duplicate field indexes #107

Closed timotheecour closed 7 years ago

timotheecour commented 7 years ago

@msoucy

import dproto.dproto;
mixin ProtocolBufferFromString!"
message A {
  repeated int32 x = 2;
  repeated int32 y = 2;
  //repeated int32 x_packed = 3 [ packed = true ];
}
";

void test3(){
  A a;
  a.x = [1,2,3];
  ubyte[] serializedObject = a.serialize();
  A a2 = A(serializedObject); // will crash at runtime here: Attempting to fetch the front of an empty array of ubyte
}
msoucy commented 7 years ago

Fixed via 5ea2b5033036f48944b7456fbda8976811660b2c