Comment #0 by bearophile_hugs — 2014-11-08T13:15:37Z
I think this whole program should be accepted:
void main() {
int[char[2]] aa;
string s = "hello";
immutable i = 1;
aa[s[i .. i + 2]] = 1; // OK
auto j = 1;
aa[s[j .. j + 2]] = 1; // Error
char[2] aux = s[j .. j + 2];
aa[aux] = 1; // OK
}
DMD 2.067alpha gives:
test.d(7,9): Error: cannot implicitly convert expression (s[cast(uint)j..cast(uint)(j + 2)]) of type string to char[2]
(In reply to Kenji Hara from comment #1)
> https://github.com/D-Programming-Language/dmd/pull/4209
Handle following slice forms:
arr[e1-b .. e2] (length = a)
arr[e1 .. e2+b] (length = b)
arr[e1-a .. e2+b] (length = a + b)
arr[e1+a .. e2+b] (length = b - a, if a <= b)
arr[e1-a .. e2-b] (length = a - b, if a >= b)
Requires:
1. 'e1' and 'e2' are equivalent expression that have no side effects.
2. 'a' and 'b' are (const-folded) constants.
Comment #3 by github-bugzilla — 2015-01-11T04:22:28Z