digitalmars.D.bugs - [Issue 12770] New: Array operation result assignment to static
- via Digitalmars-d-bugs (38/38) May 19 2014 https://issues.dlang.org/show_bug.cgi?id=12770
https://issues.dlang.org/show_bug.cgi?id=12770 Issue ID: 12770 Summary: Array operation result assignment to static arrays is complicated Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: DMD Assignee: nobody puremagic.com Reporter: turkeyman gmail.com I think this should work: float[4] f(float[4] a) { return (-a[])[0..$]; } Error: cannot implicitly convert expression ((-a[])[0..__dollar]) of type float[] to float[4] What I was actually trying to do, is perform array operations on static arrays. I'd like to think this should work: float[4] f(float[4] a) { return -a; } I tend not to think of static arrays like arrays, they're more like a discreet object. 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 []. At very least, this should probably work: float[4] f(float[4] a) { return -a[]; } --
May 19 2014