[Issue 20863] New: Pass into template by alias drops qualifier

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon May 25 18:30:05 UTC 2020


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

          Issue ID: 20863
           Summary: Pass into template by alias drops qualifier
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: andrei at erdani.com

Took me a while to make this 100% self-contained. Both asserts should pass. The
second fails.

alias AliasSeq(Seq...) = Seq;

template staticIndexOf(alias T, TList...)
{
    static if (TList.length == 0)
    {
        enum int staticIndexOf = -1;
    }
    else static if (is(T == TList[0]))
    {
        enum int staticIndexOf = 0;
    }
    else
    {
        private enum int t = staticIndexOf!(T, TList[1 .. $]);
        enum int staticIndexOf = t < 0 ? t : t + 1;
    }
}

struct Foo {}

static assert(staticIndexOf!(Foo, AliasSeq!(Foo)) == 0); // pass
static assert(staticIndexOf!(immutable(Foo), AliasSeq!(immutable(Foo))) == 0);
// fail

--


More information about the Digitalmars-d-bugs mailing list