On Wednesday, 6 January 2021 at 18:22:32 UTC, Nick Treleaven
wrote:
Type inference for parameters with a default argument could be
made to work.
auto fun(auto a = [1,2,3].staticArray) {return a;}
Okay that was a bad example. But see Luhrels answer to Jacob.
```
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.
```
int[] x = something;
int y = something[0 .. staticArrFunc(cast(int[$])[1,2,3])];
```
Excellent point, but it isn't just casts, anywhere you use a
type (template instantiation) that is within an indexing
expression will have this problem.
Yeah, this is just the simplest example that came to mind.