Skip to content

Commit 6949a54

Browse files
committed
fix Issue 18480 - dmd 2.079 hangs
1 parent 670d0ad commit 6949a54

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

src/dmd/access.d

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,8 +547,7 @@ public Dsymbol mostVisibleOverload(Dsymbol s)
547547
{
548548
if (!s.isOverloadable())
549549
return s;
550-
551-
Dsymbol next, fstart = s, mostVisible = s;
550+
Dsymbol next, fstart = s, mostVisible = s, previous = null;
552551
for (; s; s = next)
553552
{
554553
// void func() {}
@@ -593,7 +592,10 @@ public Dsymbol mostVisibleOverload(Dsymbol s)
593592
*/
594593
auto aliasee = ad.toAlias();
595594
if (aliasee.isFuncAliasDeclaration || aliasee.isOverDeclaration)
595+
{
596+
error(ad.loc, "`alias X = X` not allowed (with `X = %s`)", ad.toChars());
596597
next = aliasee;
598+
}
597599
else
598600
{
599601
/* A simple alias can be at the end of a function or template overload chain.
@@ -613,6 +615,13 @@ public Dsymbol mostVisibleOverload(Dsymbol s)
613615

614616
if (next && mostVisible.prot().isMoreRestrictiveThan(next.prot()))
615617
mostVisible = next;
618+
619+
// fixes https://issues.dlang.org/show_bug.cgi?id=18480
620+
if(next && next == previous)
621+
{
622+
return next;
623+
}
624+
previous = s;
616625
}
617626
return mostVisible;
618627
}

0 commit comments

Comments
 (0)