www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23863] New: `typeof` rejects `AliasSeq!()` as argument

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 puremagic.com
          Reporter: maxsamukha 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;

--
Apr 26 2023