cerealed icon indicating copy to clipboard operation
cerealed copied to clipboard

ArrayLength attribute doesn't work properly on char[] array

Open togrue opened this issue 7 years ago • 1 comments

The following Testcase fails at runtime:

struct TestStruct {
    ubyte len;
    @ArrayLength("len") char[] foo;
}

auto decerealiser = Decerealiser([2, 1, 2]);
// CerealException: "@ArrayLength of 2 units of type dchar (4 bytes) larger than remaining byte array (2 bytes)"
auto ts = decerealiser.value!TestStruct;
assert(ts.foo == ['\x01', '\x02']);
assert(ts.foo.length == 2);

togrue avatar Aug 15 '16 19:08 togrue

I think you can blame this one on auto-decoding. I suggest using ubyte instead.

atilaneves avatar Aug 29 '16 12:08 atilaneves