float[] f(float[] a)
{
return -a[];
}
Internal error: e2ir.c 1834
DMD 2.065 w/ -m64
Here's what I was actually trying to do at the time:
float[4] f(float[4] a)
{
return (-a[])[0..4];
}
Here's another permutation. It'd be nice if it could work out what '$' was at compile time:
float[4] f(float[4] a)
{
return (-a[])[0..$]; // use dollar instead of explicit '4'
}
Error: cannot implicitly convert expression ((-a[])[0..__dollar]) of type float[] to float[4]
Ideally, this should work with static arrays:
float[4] f(float[4] a)
{
return -a;
}
requiring a[] causes a to become a dynamic array, and then it can't be assigned back to a static array anymore. It all goes south for array operations on static arrays with [].
(In reply to Manu from comment #0)
> requiring a[] causes a to become a dynamic array, and then it can't be
> assigned back to a static array anymore. It all goes south for array
> operations on static arrays with [].
In my humble opinion, if the boundaries of an array operation could be known at compile-time, the array-op result should be convertible to static array type.
Could you file it as a new enhancement issue?