Possible compiler error when using the foreach construct

16 views
Skip to first unread message

Casey Casalnuovo

unread,
Oct 5, 2016, 2:43:23 PM10/5/16
to Boa Language and Infrastructure User Forum
While testing out queries on Boa I came across a case where looping over the values of a map with the foreach construct produced a compile error with no message.  However, when I altered the program to the equivalent for statement (as described in the documentation here: http://boa.cs.iastate.edu/docs/quantifiers.php) the program compiled and ran.  I've simplified the programs a bit to give a more minimal test case to reproduce the error.  I've attached a version that compiles and runs (noCompileError.boa) and one that fails to compile (compileError.boa) when running on the 2015 Github/Small dataset.  From my understanding, these programs should behave identically.

Is this an error in how the compiler handles the foreach structure, or have I misunderstood the documentation?
compileError.boa
noCompileError.boa

Robert E Dyer

unread,
Oct 5, 2016, 2:54:56 PM10/5/16
to boa-...@googlegroups.com
Hi Casey,

Indeed you seem to have hit a compile error.  Essentially, the foreach you wrote is doing an implicit ‘def()’ around the condition (to make that expression into a boolean).  And it appears that calling ‘def(auth_array[i])’ generates some strange Java code of the form auth_array[i] != null.  This fails to compile (with javac) because the LHS is a long.

I filed this as a new issue with the compiler, which you can see here:


- Robert

On Oct 5, 2016, at 2:43 PM, Casey Casalnuovo <cca...@ucdavis.edu> wrote:

<compileError.boa>

________________________________________________
Robert Dyer | Assistant Professor | Department of Computer Science
BGSU | rd...@bgsu.edu | 419.372.3469 | 244 Hayes | Bowling Green, OH

Want to mine ultra-large-scale software repositories with minimal initial
investment? Check out Boa! http://boa.cs.iastate.edu/

Casey Casalnuovo

unread,
Oct 5, 2016, 4:05:57 PM10/5/16
to Boa Language and Infrastructure User Forum
Okay, thank you.  Hopefully you can fix it without too much trouble.
Reply all
Reply to author
Forward
0 new messages