> As an example, VARARGPREP is tagged as A ("instruction sets register A")
> even though it doesn't. This means that e.g. a `function(...) return end`
> (which has maxstacksize == 0) would fail a generic luaP_opmodes-based test
> for supposedly writing an out-of-bounds register.
This sounds more like a bug than an example. We should fix that.
This is more like a chicken-egg issue. As there was no interest in
bytecode validation, we removed those extra checks.
Your overall analysis seems correct: type assumptions (OP_FORLOOP,
OP_SETLIST, others?) are not very expensive to be done at runtime.
Block/scope information is necessary, but I am not sure how we could
easily encode that in a usable and sensible way.
Besides opcodes, a validator would also need to check all the extra data
on a binary chunk (debug info, line info, etc.).
-- Roberto