www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8353] New: Array of polymorphic objects does not compile

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

           Summary: Array of polymorphic objects does not compile
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: jens.k.mueller gmx.de



A student of ours discovered the following non-compiling code:

class Base { }                                                                  
class A : Base { }                                                              
class B : Base { }                                                              

unittest                                                                        
{                                                                               
  auto c = [ new A, new B ]; // fails to compile but shouldn't A/B be
implicitly 
                             // convertible to Base
}

We think the code should compile. c should be an array of Base. As a work
around you can add explicit casts to Base.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 06 2012
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8353


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |yebblies gmail.com
         Resolution|                            |DUPLICATE



*** This issue has been marked as a duplicate of issue 5498 ***

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