diff --git a/docs/source/todo.rst b/docs/source/todo.rst index 53f170517..e0fff641b 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -1,7 +1,7 @@ TODO ==== -- BUG: fix @initonce for variables that end up in zeropage. +- BUG: fix @initonce for variables that end up in zeropage. They remain uninitialized altogether now. Fix it or don't allow it? - add unit tests for @initonce variables - add docs about variables with @initonce initialization diff --git a/examples/test.p8 b/examples/test.p8 index 1347a1823..c7e34f172 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -1,6 +1,8 @@ %import textio %option no_sysinit -%zeropage dontuse +%zeropage basicsafe + +; INIT ONCE tests main { sub start() { @@ -26,6 +28,11 @@ main { dump() txt.nl() + repeat 10 { + footgun() + } + txt.nl() + sub dump() { txt.print_uw(w0) txt.spc() @@ -47,4 +54,12 @@ main { txt.nl() } } + + sub footgun() { + ; TODO should just be a nonlocal variable outside of the subroutine...? + ubyte @shared @initonce @requirezp variable = 42 ; BUG: is never initialized now + txt.print_ub(variable) + txt.spc() + variable++ + } }