[chuck-users] Inner loop array index bug

Stefan Blixt stefan.blixt at gmail.com
Thu Apr 23 01:42:52 EDT 2009

Aha... I agree that's a bit weird. Perhaps lines like these:
y => int z;

are seen as an initialization of z, where y can be taken from the outer
scope, and not treated the same as

int z;
y=> z;


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

> On 22 Apr 2009, at 21:01, Stefan Blixt wrote:
>  Compilers can't always be expected to understand every kind of error, and
>> that error message isn't the worst I've seen :) Still, if the opportunity os
>> there to change it to something better, now harm done. The situation can be
>> translated to this:
>> int x;
>> 1 => x[1];
>> which gives the same subscript error message. Hans's code is otherwise
>> without problems - ChucK allows (like many other languages) to reuse a
>> variable identifier in a new block, so x can be redeclared as an int in the
>> inner while loop, overshadowing the outer x which is an array.
> The problem is really that 'chuck' accepts
>   x[msg.which] => int x;
> Then when a line after that is added
>   x[msg.which] => int x0;
> it complains about this line, giving that cryptic message, despite the fact
> that it is correct.
> When the first line is accepted, that gives the impression that this name
> overloading is legal, though it differs from C++. Thus I started to use it.
> Chuck needs to make up its mind: is this name overloading legal or not. If
> it is not, it should always be rejected.
>  Hans
> _______________________________________________
> 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/20090423/cfb6c961/attachment.html>

More information about the chuck-users mailing list