Jump to page: 1 2
Thread overview
[Issue 3543] New: : ? operator can't find common type for interfaces
Nov 23, 2009
nfxjfg@gmail.com
Nov 23, 2009
nfxjfg@gmail.com
Dec 26, 2009
nfxjfg@gmail.com
[Issue 3543] : ? operator can't find common type for classes/interfaces
Aug 28, 2010
nfxjfg@gmail.com
Nov 02, 2010
Simen Kjaeraas
Jan 07, 2011
nfxjfg@gmail.com
Jan 07, 2011
Brad Roberts
Apr 06, 2011
Walter Bright
Apr 06, 2011
Walter Bright
Apr 06, 2011
Walter Bright
Apr 06, 2011
Walter Bright
November 23, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3543

           Summary: : ? operator can't find common type for interfaces
           Product: D
           Version: 1.051
          Platform: Other
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: nfxjfg@gmail.com


--- Comment #0 from nfxjfg@gmail.com 2009-11-23 03:24:15 PST ---
The following fails to compile, but I think it should be allowed:

interface Root {
}

interface A : Root {
}

interface B : Root {
}

bool bla;

void main() {
  A a;
  B b;
  Root r;
  //this works
  r = a;
  r = b;
  //this line fails, although there's an unambiguous common type "Root"
  r = bla ? a : b;
}

If the compiler rejects this intentionally, this bug report is a feature request.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 23, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3543



--- Comment #1 from nfxjfg@gmail.com 2009-11-23 03:27:52 PST ---
This also fails if you're doing this with classes (just replace "interface"
with "class" in the example above).
With classes, this should definitely work, but it fails.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 26, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3543



--- Comment #2 from nfxjfg@gmail.com 2009-12-26 10:47:29 PST ---
Note how this makes array literal type inference suck in dmd 2.037:

class Root {
}

class A : Root {
}

class B : Root {
}

bool bla;

void main() {
  A a;
  B b;
  Root t;
  t = a; t = b; //works
  //Error: cannot implicitly convert expression (a) of type fgd.Root to fgd.B
  Root[] t2 = [a, b];
}

If this bug gets fixed, array literal type inference in D2 will be improved.

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


nfxjfg@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs@eml.cc


--- Comment #3 from nfxjfg@gmail.com 2010-08-28 16:42:33 PDT ---
*** Issue 4030 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 02, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3543


Simen Kjaeraas <simen.kjaras@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |simen.kjaras@gmail.com


--- Comment #4 from Simen Kjaeraas <simen.kjaras@gmail.com> 2010-11-02 11:30:21 PDT ---
*** Issue 5156 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 07, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3543


nfxjfg@gmail.com changed:

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


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 07, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3543


Brad Roberts <braddr@puremagic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
                 CC|                            |braddr@puremagic.com
         Resolution|WONTFIX                     |


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 06, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3543


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com


--- Comment #5 from Walter Bright <bugzilla@digitalmars.com> 2011-04-05 21:21:03 PDT ---
(In reply to comment #1)
> This also fails if you're doing this with classes (just replace "interface"
> with "class" in the example above).
> With classes, this should definitely work, but it fails.

It works with classes when I try it.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 06, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3543


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement


--- Comment #6 from Walter Bright <bugzilla@digitalmars.com> 2011-04-05 21:39:01 PDT ---
I'm going to mark this as an enhancement. When the inheritance graph is non-trivial, I don't think it's so obvious which, if any, of the ancestors should be picked. Perhaps the user should decide.

So I'm skeptical this is a good idea.

Meanwhile, it does work for classes, which make sense because classes are single inheritance. A common root, if there is one, would be only one.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 06, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3543


Andrei Alexandrescu <andrei@metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrei@metalanguage.com


--- Comment #7 from Andrei Alexandrescu <andrei@metalanguage.com> 2011-04-05 22:51:07 PDT ---
Interface hierarchies for a single-rooted DAG. In the DAG there are one or more common ancestors for any pair of nodes. The most specific one (farthest from the root) must be chosen. If there are two or more at the same depth that's an ambiguity error.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
« First   ‹ Prev
1 2