Ali Çehreli:
I don't think we are there yet. :)
Thinking some more about this topic I have created a small test
example:
uint i = 100;
void main(in string[] args) {
auto j = args.length;
ubyte x1 = (i ^^ 2) % 256; // OK
ubyte x2 = (i ^^ 3) % 256; // OK
ubyte[] arr = [(i ^^ 2) % 256, (i ^^ 3) % 256]; // OK!
ubyte y = [(i ^^ 2) % 256, (i ^^ 3) % 256][j]; // Error
}
The lines with x1 and x2 are accepted, because the range analysis
is able to infer those are in-range assignments. While the
assignment of y is refused, despite all the contents of the array
can be inferred as castable to ubyte, as shown in assignment of
arr.
I think this (the line with y) is worth an enhancement request.
Bye,
bearophile