www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2389] New: void* vs. object type overloading fails

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

           Summary: void* vs. object type overloading fails
           Product: D
           Version: 1.029
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: shro8822 vandals.uidaho.edu


one option is an exact match but it still fails? (adding a cast to void* fixes
it)

class C
{
   void opIndexAssign(void*,int){}
   void opIndexAssign(C,int){}
}

void main()
{
  C c = new C;
  c[0] = null;
}

Error:
Line 10: function C.opIndexAssign called with argument types:
        (void*,int)
matches both:
        C.opIndexAssign(void*,int)
and:
        C.opIndexAssign(C,int)


-- 
Oct 03 2008
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2389


bugzilla digitalmars.com changed:

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




------- Comment #1 from bugzilla digitalmars.com  2008-10-04 00:56 -------
null is not a simple void* like it is in C. It exact matches several different
types, including objects and void*. Hence the ambiguity.


-- 
Oct 03 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2389





------- Comment #2 from bugzilla digitalmars.com  2008-10-04 01:03 -------
I should add that this 'works' in D 2.0 because partial ordering is used to
resolve overloading conflicts.


-- 
Oct 03 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2389


shro8822 vandals.uidaho.edu changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
           Keywords|                            |diagnostic
           Priority|P2                          |P3
         Resolution|INVALID                     |
            Summary|void* vs. object type       |void* vs. object type
                   |overloading fails for null  |overloading fails for null
                   |                            |giving bad error message




------- Comment #3 from shro8822 vandals.uidaho.edu  2008-10-04 14:56 -------
The error message leave a lot to be desired.

Re-opening at low priority as a diagnostic bug.

It should be fixed "sooner or later" even if it requiters tweaking the type
system. Just like the "invalid expressions are of type null" thing.


-- 
Oct 04 2008
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2389





------- Comment #4 from shro8822 vandals.uidaho.edu  2008-10-04 15:37 -------
EDIT:

<-Just like the "invalid expressions are of type null" thing.
->Just like the "invalid expressions are of type int" thing.


-- 
Oct 04 2008