www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 16477] New: Template not properly instantiated

https://issues.dlang.org/show_bug.cgi?id=16477

          Issue ID: 16477
           Summary: Template not properly instantiated
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: johannespfau gmail.com

Reduced from the std.experimental.color code:
https://github.com/dlang/phobos/pull/2845

Commands to cause the error:


dmd std/experimental/color/rgb.d std/experimental/color/lab.d
std/experimental/color/package.d std/experimental/normint.d -lib -ofcolor.a

dmd -main -unittest std/experimental/color/lab.d color.a 

Output:

lab.o: In function
`_D3std12experimental7normint21__T13NormalizedIntTtZ13NormalizedInt11__xopEqualsFKxS3std12experimental7normint21__T13NormalizedIntTtZ13NormalizedIntKxS3std12experimental7normint21__T13NormalizedIntTtZ13NormalizedIntZb':
__main.d:(.text._D3std12experimental7normint21__T13NormalizedIntTtZ13NormalizedInt11__xopEqualsFKxS3std12experimental7normint21__T13NormalizedIntTtZ13NormalizedIntKxS3std12experimental7normint21__T13NormalizedIntTtZ13NormalizedIntZb+0xe):
undefined reference to
`_D3std12experimental7normint21__T13NormalizedIntTtZ13NormalizedInt8opEqualsMxFNaNbNiNfS3std12experimental7normint21__T13NormalizedIntTtZ13NormalizedIntZb'


Sources:


std/experimental/color/lab.d:
-----------------------------------------
import std.experimental.normint;
-----------------------------------------


std/experimental/color/package.d:
-----------------------------------------
module std.experimental.color;
import std.experimental.color.rgb;

enum aliceBlue = RGB!(ubyte)();
-----------------------------------------


std/experimental/color/rgb.d:
-----------------------------------------
module std.experimental.color.rgb;
import std.experimental.normint;
import std.typecons ;

struct RGB(ComponentType_)
{
    alias ComponentType = NormalizedInt!ComponentType_;
    enum components_ = "rgba";

    template Components(string components)
    {
            enum Components = ComponentType.stringof ~ ' ' ~ components[0] ~
";\n" ;
    }
    mixin(Components!components_);

     property tristimulus()
    {
            return tuple(r);
    }

    unittest
    {
        // test linear conversion
        alias lRGBA = RGB!(ushort);
    }
}
-----------------------------------------


std/experimental/normint.d:
-----------------------------------------
module std.experimental.normint;

import std.experimental.color;
struct NormalizedInt(I)
{
    bool opEquals(NormalizedInt) const
    {
        return true;
    }
}

-----------------------------------------

--
Sep 08 2016