[Issue 23863] New: `typeof` rejects `AliasSeq!()` as argument

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Apr 26 07:07:38 UTC 2023


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

          Issue ID: 23863
           Summary: `typeof` rejects `AliasSeq!()` as argument
           Product: D
           Version: D2
          Hardware: Other
                OS: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: maxsamukha at gmail.com

import std.meta: AliasSeq;

struct S
{
}
alias Empty = S.tupleof;
Empty x; // accepts valid

AliasSeq!() x2 = AliasSeq!(); // accepts valid
static assert(is(typeof(S.tupleof) == AliasSeq!())); // accepts valid

static assert(is(typeof(Empty) == AliasSeq!())); // rejects valid
static assert(is(typeof(AliasSeq!()) == AliasSeq!())); // rejects valid

----

This bug causes problems for generic code. For example:

import std.meta: Filter;

struct S
{
    int x;
}

template Const(alias value)
{
    enum Const(A...) = value;
}

typeof(Filter!(Const!true, S.tupleof)) s1; // passes

// but this fails - a special case is required for the empty tuple
typeof(Filter!(Const!false, S.tupleof)) s2;

--


More information about the Digitalmars-d-bugs mailing list