I thought it's a fast fix, just adding some documentation and a unittest. But when running the style checker I got into trouble. A shortend version of the problem:

I added the following public unittest to writeUpToNextSpec in std.format:

    ///
    @safe unittest
    {
        import std.array;
        auto w = appender!(char[])();

        auto f = FormatSpec("input: %10d output: %s");
        assert(f.writeUpToNextSpec(w) == true);

        assert(w.data == "input: ");
        assert(f.spec == 'd');
        assert(f.width == 10);

        // [...]
    }

While it works with the normal unittest test routines (make -f posix.mak unittest) the stylechecker complains (make -f posix.mak style).

I meanwhile found out, that I have to add the template parameter dchar to FormatSpec, although I don't understand why. (I know, that these tests should work, when they are put into a separate file. But I do not understand why the original version doesn't work there.)

But more problematic: When I add this templete parameter, I still get an error from the style checker, this time it's a linker problem, and I'm completely lost here. The error does not occure when checking std.format, but when checking std.package:

parsing std/package.d
/usr/bin/ld: std_package.o: in function `_D3std6format__T10FormatSpecTaZQp22__unittest_L1237_C11_1FNaNfZv':
__main.d:(.text._D3std6format__T10FormatSpecTaZQp22__unittest_L1237_C11_1FNaNfZv[_D3std6format__T10FormatSpecTaZQp22__unittest_L1237_C11_1FNaNfZv]+0x17):
 undefined reference to `_D3std6format__T10FormatSpecTwZQp6__initZ'
/usr/bin/ld: __main.d:(.text._D3std6format__T10FormatSpecTaZQp22__unittest_L1237_C11_1FNaNfZv[_D3std6format__T10FormatSpecTaZQp22__unittest_L1237_C11_1FNaNfZv]+0x38): undefined reference to `_D3std6format__T10FormatSpecTwZQp6__ctorMFNaNbNcNiNfxAwZSQCdQCc__TQByTwZQCe' /usr/bin/ld: std_package.o: in function `_D3std6format__T10FormatSpecTwZQp__T17writeUpToNextSpecTSQCd5array__T8AppenderTAaZQnZQBxMFNaNlNfKQBpZb':
__main.d:(.text._D3std6format__T10FormatSpecTwZQp__T17writeUpToNextSpecTSQCd5array__T8AppenderTAaZQnZQBxMFNaNlNfKQBpZb[_D3std6format__T10FormatSpecTwZQp__T17writeUpToNextSpecTSQCd5array__T8AppenderTAaZQnZQBxMFNaNlNfKQBpZb]+0x15a):
 undefined reference to `_D3std6format__T10FormatSpecTwZQp6fillUpMFNaNlNfZv'


What do I miss?

Reply via email to