TIC-80 icon indicating copy to clipboard operation
TIC-80 copied to clipboard

BOOT() doesn't throw errors until TIC() runs

Open Weeppiko opened this issue 2 years ago • 5 comments

There is some weird behaviour where if an error happens during BOOT it will not being thrown until TIC() runs for the first time. The problem is if something during TIC() relies on stuff that were supposed to be set on BOOT, this other error will be thrown instead. A simple example to reproduce it would be this:

function BOOT()
 error('BOOT error')
end
function TIC()
 error('TIC error')
end

This will show the "TIC error", but if you remove it then the "BOOT error" appears

Weeppiko avatar Jul 13 '23 16:07 Weeppiko

image hmm, I see both errors

nesbox avatar Jul 31 '23 18:07 nesbox

So I assume it is fixed then, since this happens on the latest release version (1.0.2164). But just to make sure, TIC error should NOT appear if the BOOT error happens first.

Weeppiko avatar Aug 02 '23 18:08 Weeppiko

I think this is a limitation to how the callbacks work... BOOT is just fired - and then TIC is fired... I don't recall there being a check after each callback to see if there was an error raised during that callback that should stop the VM. I think that check might only be on TIC itself. That's my guess at least.

joshgoebel avatar Aug 04 '23 04:08 joshgoebel

Okay, only now i realized it shows both errors but the second error will almost always be irrelevant or making no sense at all if it is caused by BOOT failing

Weeppiko avatar Aug 04 '23 19:08 Weeppiko

Okay, only now i realized it shows both errors

Yeah, I'd say that's a bug we should fix... that is BOOT hits an error, runtime is suspended before TIC is called.

joshgoebel avatar Aug 05 '23 03:08 joshgoebel