Bug 19884 – [regression] Error: alias op = op; cannot alias itself, use a qualified name to create an overload set
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2019-05-18T15:05:53Z
Last change time
2019-11-22T00:57:22Z
Keywords
pull
Assigned to
No Owner
Creator
hsteoh
Comments
Comment #0 by hsteoh — 2019-05-18T15:05:53Z
This regression is so strange that I'm not sure what's the best title for the bug beyond the compiler's strange error message.
Reduced code:
------
mixin template genCtEvaluate()
{
void evaluate(alias op)() { }
}
struct S
{
mixin genCtEvaluate!() mixinEval;
alias evaluate = mixinEval.evaluate;
void evaluate() { }
}
alias List(Ops...) = Ops;
void main()
{
S g;
foreach (op; List!(0))
{
g.evaluate!op();
}
}
------
Compiler output:
------
expr.d(3): Error: alias op = op; cannot alias itself, use a qualified name to create an overload set
expr.d(17): while looking for match for evaluate!op
------
This error is very strange, because 'op' is supposed to be a local symbol in the scope of the foreach, so why does it clash with the 'op' in the 'alias op' parameter of genCtEvaluate.evaluate?
Furthermore, renaming the alias parameter, e.g., to `alias _op` elicits this even stranger error message:
------
expr.d(17): Error: undefined identifier op
expr.d(17): while looking for match for evaluate!op
------
Very odd, since op is declared right in the line above as the foreach loop variable.
Also, this strange behaviour goes away if the `void evaluate() {}` overload is commented out.
This is a recent regression, though I haven't compiled the unreduced version of this code for a while now, so not 100% sure exactly when the regression was introduced. For sure it works back in 2.079.0.
Comment #1 by hsteoh — 2019-05-18T15:11:50Z
Git bisect found the bad commit: 3e22ae81b18d6caa57865aaa3e0d48ea6678903a (dmd PR #9769 - fix issue 9029).
Comment #2 by dlang-bot — 2019-11-21T13:45:28Z
@StianGulpen created dlang/dmd pull request #10599 "fix issue 19884 - [regression] Error: alias op = op; cannot alias its…" fixing this issue:
- fix issue 19884 - [regression] Error: alias op = op; cannot alias itself, use a qualified name to create an overload set
https://github.com/dlang/dmd/pull/10599
Comment #3 by dlang-bot — 2019-11-22T00:57:22Z
dlang/dmd pull request #10599 "fix issue 19884 - [regression] Error: alias op = op; cannot alias its…" was merged into stable:
- 2bf46b6365843868b465954077d6a4a09c023d45 by Stian Gulpen:
fix issue 19884 - [regression] Error: alias op = op; cannot alias itself, use a qualified name to create an overload set
https://github.com/dlang/dmd/pull/10599