Compilers can&#39;t always be expected to understand every kind of error, and that error message isn&#39;t the worst I&#39;ve seen :) Still, if the opportunity os there to change it to something better, now harm done. The situation can be translated to this:<div>
<br></div><div><div>int x;</div><div>1 =&gt; x[1];</div><div><br></div><div>which gives the same subscript error message. Hans&#39;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.</div>
<div><br></div><div>/Stefan</div><br><div class="gmail_quote">On Wed, Apr 22, 2009 at 5:55 PM, Hans Aberg <span dir="ltr">&lt;<a href="mailto:haberg@math.su.se">haberg@math.su.se</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On 22 Apr 2009, at 17:17, Kassen wrote:<br>
<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

I think ChucK can get pretty confused about this line:<br>
<br>
x[msg.which] =&gt; int x;<br>
<br>
...in which x is treated both as an array and as a newly declared integer<br>
variable. I would rename the array to avoid confusion.<br>
</blockquote></div>
... I do think ChucK could come up with a better complaint<div class="im"><br>
than this;<br>
<br>
[unnamed1]:line(20): array subscripts (1) exceeds defined dimension (0)<br>
<br>
With this test code it goes right;<br>
<br>
int x[2];<br>
int x;<br>
<br>
And we get a rather appropriate<br>
<br>
[unnamed1]:line(2): &#39;x&#39; has already been defined in the same scope...<br>
</div></blockquote>
<br>
The problem is really that if I remove the second line of:<div class="im"><br>
   x[msg.which] =&gt; int x;<br></div><div class="im">
   x[msg.which] =&gt; int x0;<br></div>
then the first<div class="im"><br>
   x[msg.which] =&gt; int x;<br></div>
is accepted.<br>
<br>
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++).<br><font color="#888888">
<br>
  Hans</font><div><div></div><div class="h5"><br>
<br>
<br>
_______________________________________________<br>
chuck-users mailing list<br>
<a href="mailto:chuck-users@lists.cs.princeton.edu" target="_blank">chuck-users@lists.cs.princeton.edu</a><br>
<a href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users" target="_blank">https://lists.cs.princeton.edu/mailman/listinfo/chuck-users</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Release me, insect, or I will destroy the Cosmos!<br>
</div>