spencersalazar / chuck

28 stars 8 forks source link

Certain syntax crashes miniAudicle compiler #19

Open spencersalazar opened 10 years ago

spencersalazar commented 10 years ago

I came across this problem when trying to run code someone had posted in the forums.

It appears that miniAudicle crashes when it tries to compile code that uses comma array syntax. By "crash" I mean it just quits-- the app terminates. (I'm running on OSX 10.8).

See the example that I whittled down to, below. If you use line B it runs fine. If you use line A it crashes.

I'm not sure whether line A is legal chuck syntax. But it's an easy mistake since some languages do index 2D arrays that way. And it's difficult to locate the problem when the app just evaporates. My guess is that yacc identifies "0,0" as a list of array elements, but the code generator doesn't recognize that as illegal in the context of an array lookup.

[[146.832 , 174.614 , 220.000], // Dm
 [164.814 , 195.998 , 246.942], // Em
 [174.614 , 220.000 , 261.626], // F
 [195.998 , 246.942 , 293.665], // G
 [220.000 , 261.626 , 329.628], // Am
 [246.942 , 293.665 , 349.228], // Bdim
 [261.626 , 329.628 , 391.995], // C
 [293.665 , 349.228 , 440.000]] // Dm
  @=> float chords[][];
chords[0,0] => float rootFreq;        // line A
//chords[0][0] => float rootFreq;     // line B
<<< rootFreq >>>;
spencersalazar commented 10 years ago

See https://class.coursera.org/chuck101-001/forum/thread?thread_id=620