www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21891] New: Cannot alias every kind that can be passed via

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

          Issue ID: 21891
           Summary: Cannot alias every kind that can be passed via
                    variadic templates
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: andrei erdani.com

Consider:

template A(X...) {
    alias Y = X[0];
}

void main()
{
    auto x = A!(1).Y;
}

This code fails because the expression `1` cannot be aliased.

Everything that can be passed via variadic arguments MUST also be bindable to
an alias. Otherwise - as is currently the case - there are subtle differences
between what can be passed as alias parameter vs. variadic parameter.

The infuriating part is that this _does_ compile!

template A(alias X) {
    alias Y = X;
}

void main()
{
    auto x = A!(1).Y;
}

So in fact 1 is bindable to an alias but somehow not in all contexts!

--
May 03