[chuck-users] Inner loop array index bug

Stefan Blixt stefan.blixt at gmail.com
Wed Apr 22 10:18:46 EDT 2009


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.

/Stefan

On Wed, Apr 22, 2009 at 2:04 PM, Hans Aberg <haberg at math.su.se> wrote:

> I encountered what looks like a bug. In the sample code below, the array
> indexing in the line with the assignment of x0 causes the following error:
>  [bug597534.ck]:line(22): array subscripts (1) exceeds defined dimension
> (0)
> It does not happen when the same kind of construct is used in the top loop,
> also as in the example code.
>
>  Hans Aberg
>
>
> ----
> Hid kb;
> HidMsg msg;
>
> if(!kb.openKeyboard(0)) me.exit();
> <<< "Keyboard '", kb.name(), "' ready." >>>;
>
> // Key x-axis coordinate
> int x[256];
>
> while(true)
> {
>  kb => now;
>
>  x[msg.which] => int y;
>  x[msg.which] => int y0;
>
>  while(kb.recv(msg))
>  {
>    x[msg.which] => int x;
>    x[msg.which] => int x0;
>  }
> }
> ----
> _______________________________________________
> chuck-users mailing list
> chuck-users at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>



-- 
Release me, insect, or I will destroy the Cosmos!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20090422/3b33f2f8/attachment.htm>


More information about the chuck-users mailing list