www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4030] New: Better object array literal type inference

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

           Summary: Better object array literal type inference
           Product: D
           Version: future
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc


--- Comment #0 from bearophile_hugs eml.cc 2010-03-30 02:59:07 PDT ---
In the following D2 program the compiler can refuse the line 6, because it must
refuse to guess (if p1 is an array of A or B).

But at line 7 the compiler has enough information to not guess (it's an array
of A), so line 7 can be accepted by the compiler:


class A {}
class B : A {}
final class C1 : B {}
final class C2 : B {}
void main() {
    auto p1 = [new C1, new C2]; // line 6, don't guess
    A[]  p2 = [new C1, new C2]; // line 7, no need to guess
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 30 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4030


klickverbot <code klickverbot.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |code klickverbot.at


--- Comment #1 from klickverbot <code klickverbot.at> 2010-08-28 16:23:02 PDT
---
There is an even shorter example which fails on DMD 2.048:
---
class A {}
class B {}

void main() {
   Object[] foo = [ new A, new B ];
}
---

TDPL has: "The element type of the array is determined by agreement among all
elements of the array, which is computed by means of the conditional operator ?
: (anticipating  2.3.16)."

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 28 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4030


nfxjfg gmail.com changed:

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


--- Comment #2 from nfxjfg gmail.com 2010-08-28 16:42:33 PDT ---
*** This issue has been marked as a duplicate of issue 3543 ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 28 2010