Don't cast local/lexical indexes to 8-bit!

They're meant to be 16. Also detect the out-of-range local case.