atilaneves / cerealed

Powerful binary serialisation library for D
BSD 3-Clause "New" or "Revised" License
92 stars 3 forks source link

Serializing ubyte[] fails to compile #7

Closed ColonelThirtyTwo closed 8 years ago

ColonelThirtyTwo commented 8 years ago

Attempting to serialize a ubyte[] array results in a compiler error. Line 130 in cereal.d attempts to call dup on length, which isn't an array.

Test Program:

void main() {
    auto test = new ubyte[5];

    auto cerealiser = Cerealiser();
    cerealiser ~= test;

    auto deceralizer = Decerealizer(cerealiser.bytes);
    auto testcpy = deceralizer.value!(ubyte[]);

    assert(test == testcpy);
}

Output

> dub build
Target cerealed 0.6.1 is up to date. Use --force to rebuild.
Building test ~master configuration "application", build type debug.
Compiling using dmd...
../.dub/packages/cerealed-0.6.1/src/cerealed/cereal.d(130): Error: template object.dup cannot deduce function from argument types !()(short), candidates are:
/usr/include/dmd/druntime/import/object.d(1785):        object.dup(T : V[K], K, V)(T aa)
/usr/include/dmd/druntime/import/object.d(1821):        object.dup(T : V[K], K, V)(T* aa)
/usr/include/dmd/druntime/import/object.d(3122):        object.dup(T)(T[] a) if (!is(const(T) : T))
/usr/include/dmd/druntime/import/object.d(3138):        object.dup(T)(const(T)[] a) if (is(const(T) : T))
/usr/include/dmd/druntime/import/object.d(3149):        object.dup(T : void)(const(T)[] a)
../.dub/packages/cerealed-0.6.1/src/cerealed/cereal.d(110): Error: template instance cerealed.cereal.decerealiseArrayImpl!(Decerealiser, ubyte[], short) error instantiating
../.dub/packages/cerealed-0.6.1/src/cerealed/decerealiser.d(63):        instantiated from here: grain!(Decerealiser, ubyte[], short)
source/app.d(18):        instantiated from here: value!(ubyte[], short)
FAIL .dub/build/application-debug-linux.posix-x86_64-dmd_2068-52E1E9557A38487A968910C60DCC3586/ test executable
Error executing command build:
dmd failed with exit code 1.