www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12559] New: Multi operators with template mixins produces an

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

          Issue ID: 12559
           Summary: Multi operators with template mixins produces an error
           Product: D
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: temtaime gmail.com

mixin template T() {
    S opBinary(string s)(S s) { return S(); }     
}

struct S {
    S opBinary(string s)(S s) if(0) { return S(); }     

    mixin T;
}

void main() {
    S a, b;
    a + b;    
}

Error: incompatible types for ((a) + (b)): 'S' and 'S'

But

struct S {
    S opBinary(string s)(S s) if(0) { return S(); } 
    S opBinary(string s)(S s) { return S(); } 
}

void main() {
    S a, b;
    a + b;    
}

Compiles ok

--
Apr 11 2014