[Issue 8353] New: Array of polymorphic objects does not compile

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jul 6 13:59:07 PDT 2012


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 at puremagic.com
        ReportedBy: jens.k.mueller at gmx.de


--- Comment #0 from jens.k.mueller at gmx.de 2012-07-06 13:59:05 PDT ---
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: -------


More information about the Digitalmars-d-bugs mailing list