[chuck-users] Inner loop array index bug
Hans Aberg
haberg at math.su.se
Wed Apr 22 11:55:49 EDT 2009
On 22 Apr 2009, at 17:17, Kassen wrote:
>> I think ChucK can get pretty confused about this line:
>>
>> x[msg.which] => int x;
>>
>> ...in which x is treated both as an array and as a newly declared
>> integer
>> variable. I would rename the array to avoid confusion.
> ... I do think ChucK could come up with a better complaint
> than this;
>
> [unnamed1]:line(20): array subscripts (1) exceeds defined dimension
> (0)
>
> With this test code it goes right;
>
> int x[2];
> int x;
>
> And we get a rather appropriate
>
> [unnamed1]:line(2): 'x' has already been defined in the same scope...
The problem is really that if I remove the second line of:
x[msg.which] => int x;
x[msg.which] => int x0;
then the first
x[msg.which] => int x;
is accepted.
So when I add the second line, I get a confusing error message about
that, not about the first one, which seemed a legal name overload
(though differing from C++).
Hans
More information about the chuck-users
mailing list