[Issue 2006] Appending empty array using ~= doesn't work

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jan 28 06:41:30 PST 2011


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


Denis Derman <denis.spir at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |denis.spir at gmail.com


--- Comment #5 from Denis Derman <denis.spir at gmail.com> 2011-01-28 06:39:21 PST ---
(In reply to comment #3)
> I just got bitten by this again.
> 
> float[][] arr;
> arr ~= [1.0]; // ok, adds a new element (an array of length 1).
> arr ~= []; // not ok, does nothing. :-(
> 
> The last line there does nothing, apparently because the compiler interprets it
> to be an array of array that's empty, which is the least useful interpretation.
>  So I find it unexpected that the compiler interprets it this way.  Once
> again... even though I already ran into it once.  I just forgot because it
> seems so silly for the compiler to choose the interpretation that it does.
> 
> At the very least I'd like the compiler to generate an error saying it doesn't
> know how to interpret 'arr ~= []'.

Yes, ambiguity that is bug-prone, because both interpretations can run, must
yield compiler error.

Denis

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