Discussion Thread: DIP 1039--Static Arrays with Inferred Length--Community Review Round 1
Nick Treleaven
nick at geany.org
Wed Jan 6 18:41:31 UTC 2021
On Wednesday, 6 January 2021 at 18:33:54 UTC, Dukc wrote:
>>> ```
>>> int[$] bar(int[2] arr) // Error: not allowed in
>>> functions declarations
>>> {
>>> return arr ~ [3, 4];
>>> }
>>> ```
>>
>> causes an error if the return type is specified as int[4].
>
> Why? `arr` is static so the compiler should be able to figure
> that no overflow will ever happen.
Because:
1. concatenation with a static array is not defined (use `arr[]`).
2. slices do not implicitly convert to a static array.
More information about the Digitalmars-d-announce
mailing list