[Issue 21891] New: Cannot alias every kind that can be passed via variadic templates

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon May 3 19:52:16 UTC 2021


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 at puremagic.com
          Reporter: andrei at 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!

--


More information about the Digitalmars-d-bugs mailing list