www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4258] New: "auto ref" doesn't work in one or more cases

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

           Summary: "auto ref" doesn't work in one or more cases
           Product: D
           Version: unspecified
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc


--- Comment #0 from bearophile_hugs eml.cc 2010-06-01 10:11:15 PDT ---
I think this is a correct D2 program:


struct Vec {
    Vec opOpAssign(string Op)(auto ref Vec other) if (Op == "+=") {
        return this;
    }
    Vec opBinary(string Op:"+")(Vec other) {
        Vec result;
        return result += other;
    }
}
void main() {
    Vec v;
    v += Vec() + Vec(); // line 12
}


But DMD v2.046 prints:
temp.d(12): Error: function temp.Vec.opOpAssign!("+=").opOpAssign (auto ref Vec
other) is not callable using argument types (Vec)
temp.d(12): Error: (Vec()).opBinary((Vec())) is not an lvalue

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 01 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4258


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich gmail.com


--- Comment #1 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2010-08-30
06:42:08 PDT ---
I get different errors with 2.048:

bug4258.d(7): Error: 'result' is not a scalar, it is a Vec
bug4258.d(7): Error: 'result' is not of arithmetic type, it is a Vec
bug4258.d(7): Error: 'other' is not of arithmetic type, it is a Vec
bug4258.d(12): Error: template instance bug4258.Vec.opBinary!("+") error
instantiating
bug4258.d(12): Error: 'v' is not a scalar, it is a Vec

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 30 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4258


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch, rejects-valid
                 CC|                            |k.hara.pg gmail.com
           Platform|x86                         |All
         OS/Version|Windows                     |All


--- Comment #2 from Kenji Hara <k.hara.pg gmail.com> 2011-04-29 20:42:29 PDT ---
Patch create and send pull request:
https://github.com/D-Programming-Language/dmd/pull/51

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 29 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4258


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla digitalmars.com


--- Comment #3 from Walter Bright <bugzilla digitalmars.com> 2011-06-30
01:04:25 PDT ---
(In reply to comment #2)
 Patch create and send pull request:
 https://github.com/D-Programming-Language/dmd/pull/51
With the patch, the error is the same as in Andrej's comment. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 30 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4258



--- Comment #4 from Kenji Hara <k.hara.pg gmail.com> 2011-06-30 03:49:02 PDT ---
(In reply to comment #3)
Thanks for your merging.

 (In reply to comment #2)
 Patch create and send pull request:
 https://github.com/D-Programming-Language/dmd/pull/51
With the patch, the error is the same as in Andrej's comment.
Original test code is now invalid, because the template string argument of opOpAssign is just "+", not "+=". I just send pull request for adding test case. Please merge it. https://github.com/D-Programming-Language/dmd/pull/182 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 30 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4258


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


--- Comment #5 from Walter Bright <bugzilla digitalmars.com> 2011-07-01
19:52:49 PDT ---
https://github.com/D-Programming-Language/dmd/commit/ef3c8386ede421aa2756820eebc70dd03c9e58e1

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 01 2011