Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

A lua error in lua code within setup() can cause knock-on surprising issues in draw()

edited January 2012 in Bugs Posts: 29

If you have a bug in your lua code which is run during setup(), that will cause a lua error which is reported to the print window. All good and proper.

Also, the subsequent code in setup() after your error will not be run. Also reasonable.

Your code under draw() will still be run. This produces more errors, because some of your setup code was not run. This situation was a bit perplexing to me. Not for long but it certainly doesn't adhere to the principle of least surprise. I was thinking Oh yes, there is an error on line 20 in my setup. But how come there are also errors on line 550 in my drawing code? What is up with that suddenly? ... Goes off to read his drawing code.

(An aside. I notice that a lua error raised in any code under draw() will cause a [Pause], and you can [Play] your code even though it has raised errors. This is quite a nice feature, and not what I would have expected but at least the message "Pausing playback" gives you all the information. There is no such message with an error raised during setup() lua code, because play back is not paused. Also reasonable).

Comments

  • Posts: 29

    BTW I'm not suggesting that your code under draw() is not run when there is an error in setup(). I'm thinking there is a more elegant solution.

  • SimeonSimeon Admin Mod
    Posts: 5,202

    Thanks for reporting this @Martin — could you log it on the issue tracker? https://bitbucket.org/TwoLivesLeft/codea/issues

    This sounds like a bug with the way setup() is run.

  • SimeonSimeon Admin Mod
    Posts: 5,202

    Actually I noticed you are still using the previous version of Codea. We changed the say setup() is called in version 1.3. Please check to see if this issue is fixed in 1.3 before reporting it on the tracker.

  • Posts: 29

    I was completely meaning to say "Codea 1.2.6" at the end of my post, then clean forgot. Apologies.

    This bug is addressed in 1.3. Execution of code ceases after an error in setup() and in draw(). You can unpause and continue execution if you choose. It feels reasonable.

Sign In or Register to comment.