https://issues.dlang.org/show_bug.cgi?id=12032

RazvanN <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |[email protected]
         Resolution|---                         |INVALID

--- Comment #1 from RazvanN <[email protected]> ---
This issue is invalid. The first case compiles because the compiler is able to
deduce that the returned array is of size 2 (the range bounds are literal and
therefore known at compile time). The second case is an assignment of slices,
therefore the error (if any) can only be caught at runtime. In the third case,
the length of the `a` array cannot be known because `a` is a dynamic array and
any number of elements could be added or deleted from a before we return the
slice. Therefore the compiler rejects it. If a would have been a static array,
then the compiler would have accepted the code because it can statically
determine that the returned array matches the expected size.

--

Reply via email to