Code:
------
alias tuple(A...) = A;
void main() {
float[] arr;
arr[tuple!()] = 0.0;
}
------
Indexing with a tuple of 1 integral element works correctly, and indexing with a tuple of more than 1 element correctly generates an error message about non-convertibility to ulong.
Indexing with an empty tuple should also generate an error message, rather than crash.
Comment #1 by hsteoh — 2014-09-07T02:03:44Z
This patch fixes it:
-------
diff --git a/src/expression.c b/src/expression.c
index 9b8b80b..650f67a 100644
--- a/src/expression.c
+++ b/src/expression.c
@@ -10336,8 +10336,11 @@ Expression *IndexExp::semantic(Scope *sc)
if (t1->ty == Ttuple) sc = sc->endCTFE();
if (e2->type == Type::terror)
return new ErrorExp();
- if (e2->type->ty == Ttuple && ((TupleExp *)e2)->exps->dim == 1) // bug 4444 fix
+ if (e2->type->ty == Ttuple && ((TupleExp *)e2)->exps &&
+ ((TupleExp *)e2)->exps->dim == 1) // bug 4444 fix
+ {
e2 = (*((TupleExp *)e2)->exps)[0];
+ }
if (t1->ty == Tsarray || t1->ty == Tarray || t1->ty == Ttuple)
sc = sc->pop();
-------
Will submit this as a PR on Monday once internet connectivity from my home PC is restored.