Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Rock should detect invalid uses of break/continue statements #603

einat opened this Issue Feb 19, 2013 · 3 comments


None yet
3 participants

einat commented Feb 19, 2013


itemsArray each(|item|
    if (something) {

The code above generates C code (obviously invalid)

@shamanas: Edited this issue to reflect the true bug


duckinator commented Feb 19, 2013

As far as both rock and the C compiler are concerned, it is not in a loop. It is inside an ooc closure, which is compiled down to a C function. Those are then called from inside of a loop — so the result is the code is indirectly ran inside a loop, and the C compiler can't know for sure. I'm not sure if rock can be made to know, but as of right now it does not. The way each() and such has been designed, however, return true behaves like continue and return false behaves like break.

There's some more details in #158. I'll make note to document this.

@nddrylliog did I miss anything?


shamanas commented Feb 19, 2013

@duckinator Yes, indeed, there was some confusion in IRC, I'll edit the title :)


shamanas commented Feb 19, 2013

And here is the shortest possible testcase


@shamanas shamanas added a commit that referenced this issue Feb 19, 2013

@shamanas shamanas Merge pull request #604 from shamanas/master
Detect use of flow control statements outside of a loop - Closes #603

@shamanas shamanas closed this Feb 19, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment