On Wednesday, 6 January 2021 at 18:41:31 UTC, Nick Treleaven wrote:
On Wednesday, 6 January 2021 at 18:33:54 UTC, Dukc wrote:
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[]`).

Oh okay.

2. slices do not implicitly convert to a static array.

They do if the length is known at compile time, but `~` does not for some reason propagate the length. This works though:

```
int[4] bar(int[2] arr)
{   return arr.conc([3, 4]);
}

T[i+j] conc(T, size_t i, size_t j)(T[i] a, T[j] b)
{       typeof(return) result;
        result[0 .. i] = a[];
        result[i .. $] = b[];
        return result;
}
```

Reply via email to