Fix Issue 23863 - typeof rejects AliasSeq!() as argument (#15140)

This commit is contained in:
Razvan Nitu 2023-04-29 22:35:14 +03:00 committed by GitHub
parent 9db1dfc17c
commit d11ec36040
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 2 deletions

View file

@ -2804,8 +2804,10 @@ void resolve(Type mt, const ref Loc loc, Scope* sc, out Expression pe, out Type
}
mt.exp = exp2;
if (mt.exp.op == EXP.type ||
mt.exp.op == EXP.scope_)
if ((mt.exp.op == EXP.type || mt.exp.op == EXP.scope_) &&
// https://issues.dlang.org/show_bug.cgi?id=23863
// compile time sequences are valid types
!mt.exp.type.isTypeTuple())
{
if (!(sc.flags & SCOPE.Cfile) && // in (extended) C typeof may be used on types as with sizeof
mt.exp.checkType())

View file

@ -0,0 +1,15 @@
// https://issues.dlang.org/show_bug.cgi?id=23863
alias AliasSeq(T...) = T;
struct S
{
}
alias Empty = S.tupleof;
Empty x; // accepts valid
static assert(is(typeof(x)));
static assert(is(typeof(Empty)));
static assert(is(typeof(AliasSeq!(int))));
static assert(is(typeof(Empty) == AliasSeq!()));
static assert(is(typeof(AliasSeq!()) == AliasSeq!()));