[Issue 10971] assigning derived class to base should not trigger promotion of result

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Sep 5 09:18:05 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=10971



--- Comment #3 from Maxim Fomin <maxim at maxim-fomin.ru> 2013-09-05 09:18:04 PDT ---
(In reply to comment #2)
> (In reply to comment #1)
> > I doubt it will ever be implemented because it breaks static typing of D. In
> > second example type of a is "A" and not "B" and your request would require
> > compiler to accept/reject sometimes arguments depending on context. For
> > example, initializer for a can be not new B, but Object foo() and in such
> > context compiler cannot know whether returned value is trully B or not.
> 
> Depends on how you see it I guess. I could that I see it that the initializer
> is "new B", yet *because of context* (assign to "a" while we are at it), it
> doesn't compile.
> 
> But I don't think this has anything to do with context. Just that "a = b" is an
> operation, and like all operations, it has a return type. I think we could
> improve what that type is. We could make it "The type A, but implicitly
> cast-able to B"
> 
> That would be "nice to have".

In C in assignment chaining type of expression is defined to be the type of
leftmost operand. I don't think you EH is a good reason to break it.

-- 
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