This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Lupus590's profile picture

[Solved] Tried to make my code look nicer and broke it, tried another way and managed to break it differently.

Started by Lupus590, 16 April 2018 - 09:41 PM
Lupus590 #1
Posted 16 April 2018 - 11:41 PM
This is the master version of the code, it works but is not the easiest for a human to read and understand: https://github.com/C.../checkpoint.lua

To understand this code you may want to check it's test file which is unchanged over all three versions: https://github.com/C...72a7f7/test.lua



The issue I'm having is in my rewites for the intentional error detection. I have two rewrites which both approch the problem from different directions which has resulted in both having very different bugs.

This version uses two corotines (via the parallel API) to run the callbacks while listening for terminate events (assuming that a terminate is the only type of intended error which doesn't cover every case).
The bug is that the program doesn't error on the terminate, in fact it doesn't seem to notice the event at all and just continues as normal.
https://github.com/C...kpoint.lua#L183



So I began another rewrite, this time by modifying the trace back part so that it sets a flag depending on if it decided to perform a stack trace or not (it seems to have working intentional error systems, the plan here was to piggy back on that). The bug here is that it doesn't work, every error is registered as unintended which means that the terminate gives unwanted error information.
https://github.com/C.../checkpoint.lua
Edited on 19 April 2018 - 12:27 PM
Luca_S #2
Posted 17 April 2018 - 06:44 PM
So the problem occurs when changing from commit 52a71a053(master) to fddb5edac8a?
Edited on 17 April 2018 - 04:47 PM
Lupus590 #3
Posted 17 April 2018 - 07:42 PM
So the problem occurs when changing from commit 52a71a053(master) to fddb5edac8a?

Yes, and a simular but different problem (due to a different approch to the same goal) happens in f8c229d

Basically I would like fresh eyes to look for why stuff prints when it shouldn't in one commit and doesn't print when it should in another.

Edit; updated op so that it gives a general thought process on approch and things.
Edited on 17 April 2018 - 06:07 PM
Lupus590 #4
Posted 19 April 2018 - 02:18 PM
On commit fddb .it looks like the traceback code doesn't see terminates as intended errors, so my code is ok, but I was not understanding how the traceback stuff works.