import std.typecons; void main (string[] args) {/*...}*/ int[] x = [2,3,4]; writeln (x[0]); writeln (x[0.tuple.expand]); // BUG range violation }
Seems to work in git HEAD, tested on Linux/64. Maybe this has already been fixed?
I'm using git HEAD, I still get the range violation. Not only that but this: auto y = x[0]; auto z = x[0.tuple.expand]; // ok runs fine. (got rid of writeln) but also this: auto y = x[0]; writeln (x[0.tuple.expand]); // ok and this: writeln (x[0]); auto z = x[0.tuple.expand]; // ok not sure whats going on, I just recompiled dmd from the latest
this works as well: writeln (x[0]); auto y = x[0.tuple.expand]; writeln (x[0.tuple.expand]); // ok again??
its not writeln, this works as well: auto f (T...)(T) { } void main (string[] args) { int[] x = [2,3,4]; f (x[0]); auto a = x[0.tuple.expand]; // range violation if commented out f (x[0.tuple.expand]); }
It only seems to happen with T[] types, struct with opIndex to catch and print args confirms that the tuple expand call just resolves to a 0 int. Np luck catching it with gdb so far, the violation goes off as soon as that line is reached.
https://github.com/D-Programming-Language/dmd/pull/4216
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/872a1b649c3a13f3a6b1bcfdec8e6961671411eb fix Issue 13864 - tuple expand causes range violation https://github.com/D-Programming-Language/dmd/commit/626d64259c0d6d8ebbe6bb54da816558d6137306 Merge pull request #4216 from 9rnsr/fix13864 [REG2.066] Issue 13864 - tuple expand causes range violation
Commits pushed to 2.067 at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/872a1b649c3a13f3a6b1bcfdec8e6961671411eb fix Issue 13864 - tuple expand causes range violation https://github.com/D-Programming-Language/dmd/commit/626d64259c0d6d8ebbe6bb54da816558d6137306 Merge pull request #4216 from 9rnsr/fix13864