[Issue 10103] New: template mixin with property overloads
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Fri May 17 02:31:34 PDT 2013
    
    
  
http://d.puremagic.com/issues/show_bug.cgi?id=10103
           Summary: template mixin with property overloads
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: SebastianGraf at t-online.de
--- Comment #0 from Sebastian Graf <SebastianGraf at t-online.de> 2013-05-17 02:31:31 PDT ---
If you mix in getters and setters in seperate template mixins, it fails to
compile on first property-like usage. 
Strangely, you may use both overloads if you treat them like functions (e.g.
the first examples in main below).
I think this is related to http://d.puremagic.com/issues/show_bug.cgi?id=1686
and http://d.puremagic.com/issues/show_bug.cgi?id=9235.
Offending code:
mixin template Getter() {
    @property auto x() { return _x; }
}
mixin template Setter() {
    @property void x(int x) { _x = x; }
}
struct Foo {
    int _x;
    mixin Getter!(); // definition order is irrelevant
    mixin Setter!();
}
void main() {
    auto f = Foo(4);
    auto x1 = f.x(); //fine
    f.x(2); // fine
    auto x2 = f.x; // Error: expression has no value
    f.x = 3; // Error: f.x is not an lvalue
}
-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
    
    
More information about the Digitalmars-d-bugs
mailing list