digitalmars.D.bugs - [Issue 3935] New: opBinary is instantiated with "="
- d-bugmail puremagic.com (32/32) Mar 11 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3935
 - d-bugmail puremagic.com (21/21) Mar 11 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3935
 - d-bugmail puremagic.com (14/14) Mar 12 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3935
 - d-bugmail puremagic.com (21/21) Jul 28 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3935
 - d-bugmail puremagic.com (12/12) Aug 26 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3935
 
http://d.puremagic.com/issues/show_bug.cgi?id=3935
           Summary: opBinary is instantiated with "="
           Product: D
           Version: 2.041
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: mrmocool gmx.de
This is really strange behavior. It gets even stranger over time.
It once started with
Vector2f        _pos = Vector2f(0.f, 0.f);
yields:
Error: template instance opBinary!("=") matches more than one template
declaration
Now I can't seem to reproduce it anymore.
But in a bigger project, with the following code:
Vector2 opBinary(string op, U:Vector2)(U v)
{
    pragma(msg, "opBinary!"~op);
}
I get several instantiations with opBinary!=
Even though http://www.digitalmars.com/d/2.0/operatoroverloading.html#Binary
clearly states that "=" isn't overloadable which totally makes sense since
there is http://www.digitalmars.com/d/2.0/operatoroverloading.html#Assignment
-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
 Mar 11 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3935
bearophile_hugs eml.cc changed:
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs eml.cc
When you submit a bug it's better to show a minimal but complete program that
shows your problem. This shows the situation (I think it's cute, an
undocumented operator overload):
struct Foo {
    void opBinary(string op)(Foo other) {
        pragma(msg, "op: " ~ op);
    }
}
void main() {
    Foo f;
    f = f;
}
-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
 Mar 11 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3935
Trass3r <mrmocool gmx.de> changed:
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |spec, wrong-code
found the cause:
if opAssign isn't present but opBinary is, opBinary is instantiated with "=".
This could probably be fixed by replacing opover.c:458 with
if (!s && !s_r && op != TOKequal && op != TOKnotequal && op != TOKassign)
The question is if opAssign is really meant to stay.
-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
 Mar 12 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3935
Trass3r <mrmocool gmx.de> changed:
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
Sorry, just giving one line isn't good practice, so:
===================================================================
--- opover.c    (revision 589)
+++ opover.c    (working copy)
   -474,7 +474,7   
     Objects *targsi = NULL;
 #if DMDV2
-    if (!s && !s_r && op != TOKequal && op != TOKnotequal)
+    if (!s && !s_r && op != TOKequal && op != TOKnotequal && op != TOKassign)
     {   /* Try the new D2 scheme, opBinary and opBinaryRight
          */
         if (ad1)
-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
 Jul 28 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3935
Walter Bright <bugzilla digitalmars.com> changed:
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED
22:53:32 PDT ---
http://www.dsource.org/projects/dmd/changeset/630
-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
 Aug 26 2010








 
 
 
 d-bugmail puremagic.com 