www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7670] New: UFCS problem with property and structs

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7670

           Summary: UFCS problem with  property and structs
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



Modified from an example by Comrad in D.learn.


struct A {
    double x;
}
 property ref double y(ref A a) {
    return a.x;
}
void main() {
    A a1;
    a1.y() = 2.0; // OK
    a1.y = 2.0; // Error
}


DMD 2.059head gives:

test.d(10): Error: no property 'y' for type 'A', did you mean 'x'?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 08 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7670


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull



https://github.com/D-Programming-Language/dmd/pull/812

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 15 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7670


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 15 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7670




Maybe you have gone a bit too much far with your fix, Kenji Hara.

In my example code here I used  property:

 property ref double y(ref A a) {

But your patch allows that syntax even without  property.

Your patch allows _very_ nice and noise-free code like:

[1, 2, -3, 4].filter!(x => x > 0).map!(x => x ^^ 0.2).writeln;

But I think it undermines the meaning and usefulness of the -property compiler
switch and the meaning of  property.

So I suggest to think a bit more about this, to keep the nice things, and to
not throw away two baby waters.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 16 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7670




See also Bug 7722 and Bug 7723

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 18 2012