rsdn / nemerle

Nemerle language. Main repository.
http://nemerle.org
Other
618 stars 89 forks source link

Multidimensional array indexing #374

Open don-reba opened 12 years ago

don-reba commented 12 years ago
def a = array(2, 2);
WriteLine(a[(0, 1)]);

error: expected (int- * int-), got int in array index: the types int and (int- * int-) are not compatible [simple unify]

The error does not make sense. The array index is given what it expects, but then complains about being given something it is not.

ghost commented 12 years ago

Multidimensional array index must be without round braces:

    def a = array(2, 2);
    a[0, 1] = 1;
    WriteLine(a[0, 1]);

This is not issue.

don-reba commented 12 years ago

Indexing with a tuple is the point. The problem is that it does not work and that the error message inaccurately describes the problem. The real case looks more like this:

def a : array[2, int];
def b : array[int * int];
a[b[i]]; // error

If making multidimensional array indices work with tuples is too much work, it would at least be nice to have the error message fixed.