[Issue 7318] Cannot concatenate arrays of super- and subtype

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jan 19 15:05:35 PST 2012


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


Steven Schveighoffer <schveiguy at yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |schveiguy at yahoo.com


--- Comment #4 from Steven Schveighoffer <schveiguy at yahoo.com> 2012-01-19 15:05:30 PST ---
(In reply to comment #2)
> To further back up my point, this compiles, and it is not a bug:
> 
> void main(){
>     auto a = [new Object()];
>     auto b = [new Exception("")];
>     a~=b;
> }

It only is not a bug because of the special case of arrays.  That is, even
though the array function takes two mutable arguments, the compiler can deduce
that neither array will be molested (same for concatenation).

The same is not true for normal functions, you could not write the append
function in user code that accepted a derived array type without applying
const/inout to the second argument.

I agree it's not a bug, but is an enhancement.  It would also be a good
brainstorming session to figure out how to employ the same assumptions on
normal functions.

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