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





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






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





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 next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2389






EDIT:

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


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


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |WORKSFORME



02:27:38 PDT ---
Now produces:

foo.d(10): Error: function foo.C.opIndexAssign called with argument types:
        ((typeof(null),int))
matches both:
        foo.C.opIndexAssign(void* _param_0, int _param_1)
and:
        foo.C.opIndexAssign(C _param_0, int _param_1)

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