Story time: Off by one again

The last three or four days I've been stuck on this bug in the compiler where my constant indexes were always way off. I ran it through the debugger, tested the compiler and yet it was way off. Turns out I was looking in all the wrong places. Although it wasn't necessarily a bad thing. I managed to find bugs that hadn't yet been caught or tested for yet. I knew I was off by one somewhere, but the question was where. Especially since I could see the exact byte code produced by the compiler and it was exactly what was expected. For those interested I can provide a bit of context.

So far my compiler has a linked list like scope, where each method call has access to the scope of the callee but not the other way around, i.e. singly linked list. Local scope is handled by sectioning off the stack and keeping track of where the current scope starts and ends on the stack. Usually the top of the stack when a new scope was added. When you are done, you simply return back to this point. It's quite simple to implement and understand. To save/access a variable you use either opSet/opGet to then get the index of the variable in the stack so that you can use it. So far I've only had opSetGlobal/opSetGlobal and it was decided that you could save up to max(u16) number of global variables so the index was a 16 bit number. It did no seem necessary to have that many number of scoped variables so I decided to have the index to be a byte for local variables. This small detail ended up derailing me for the last three days. There was about 24 hours difference between deciding on the byte index for scoped variables and implementing them. By the time I was implementing it I totally forgot about this details. Yet in my method to emit byte code I had already implemented this. I realized this morning as the byte code looked off. That's the story of how a single implementation detail made me pull my tiny hair off for the last three mornings. Yet I live for moments like this morning, where I figure out why.

Updated after posting:
Just as a I posted I realized this is post 255, which was quite the coincidence considering this whole problem was caused by a byte index so that I could limit the number of local variables to be 255 or max(u8)