mirror of
https://github.com/dlang/dmd.git
synced 2025-04-27 21:51:03 +03:00
fix Issue 22975 - ICE: 3 cyclic aliases with meaningful overloads not caught
This commit is contained in:
parent
4b5a7826a7
commit
6a406a59fe
2 changed files with 86 additions and 63 deletions
|
@ -2924,6 +2924,15 @@ Expression addInvariant(AggregateDeclaration ad, VarDeclaration vthis)
|
|||
*/
|
||||
extern (D) int overloadApply(Dsymbol fstart, scope int delegate(Dsymbol) dg, Scope* sc = null)
|
||||
{
|
||||
Dsymbols visited;
|
||||
|
||||
int overloadApplyRecurse(Dsymbol fstart, scope int delegate(Dsymbol) dg, Scope* sc)
|
||||
{
|
||||
// Detect cyclic calls.
|
||||
if (visited.contains(fstart))
|
||||
return 0;
|
||||
visited.push(fstart);
|
||||
|
||||
Dsymbol next;
|
||||
for (auto d = fstart; d; d = next)
|
||||
{
|
||||
|
@ -2940,11 +2949,11 @@ extern (D) int overloadApply(Dsymbol fstart, scope int delegate(Dsymbol) dg, Sco
|
|||
{
|
||||
if (checkSymbolAccess(sc, od))
|
||||
{
|
||||
if (int r = overloadApply(od.aliassym, dg, sc))
|
||||
if (int r = overloadApplyRecurse(od.aliassym, dg, sc))
|
||||
return r;
|
||||
}
|
||||
}
|
||||
else if (int r = overloadApply(od.aliassym, dg, sc))
|
||||
else if (int r = overloadApplyRecurse(od.aliassym, dg, sc))
|
||||
return r;
|
||||
next = od.overnext;
|
||||
}
|
||||
|
@ -2952,7 +2961,7 @@ extern (D) int overloadApply(Dsymbol fstart, scope int delegate(Dsymbol) dg, Sco
|
|||
{
|
||||
if (fa.hasOverloads)
|
||||
{
|
||||
if (int r = overloadApply(fa.funcalias, dg, sc))
|
||||
if (int r = overloadApplyRecurse(fa.funcalias, dg, sc))
|
||||
return r;
|
||||
}
|
||||
else if (auto fd = fa.toAliasFunc())
|
||||
|
@ -3007,6 +3016,8 @@ extern (D) int overloadApply(Dsymbol fstart, scope int delegate(Dsymbol) dg, Sco
|
|||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return overloadApplyRecurse(fstart, dg, sc);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
12
compiler/test/compilable/issue22975.d
Normal file
12
compiler/test/compilable/issue22975.d
Normal file
|
@ -0,0 +1,12 @@
|
|||
// https://issues.dlang.org/show_bug.cgi?id=22975
|
||||
void test22975a(int) {};
|
||||
|
||||
alias test22975b = test22975a;
|
||||
|
||||
void test22975b(bool) {}
|
||||
|
||||
alias test22975c = test22975b;
|
||||
|
||||
alias test22975a = test22975c;
|
||||
|
||||
void test22975c(float) {}
|
Loading…
Add table
Add a link
Reference in a new issue