[Issue 19884] New: Error: alias op = op; cannot alias itself, use a qualified name to create an overload set

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat May 18 15:05:53 UTC 2019


https://issues.dlang.org/show_bug.cgi?id=19884

          Issue ID: 19884
           Summary: Error: alias op = op; cannot alias itself, use a
                    qualified name to create an overload set
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: hsteoh at quickfur.ath.cx

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.

--


More information about the Digitalmars-d-bugs mailing list