Closed Kristopher38 closed 4 years ago
Thank you @Kristopher38 appreciate the feedback. I will check and correct.
Hi @Kristopher38, strange as the comment in lopcodes.h must be wrong then? You may be right about this, I need to go through some examples to verify.
Hi @Kristopher38 Please would you review https://github.com/dibyendumajumdar/ravi/blob/master/readthedocs/lua_bytecode_reference.rst? I am still working through the various examples of bytecode
Hi, I've read through the commits and they look correct to me. The updated bytecode explanations will especially help at getting a better grasp of what exactly is the execution flow of those opcodes.
Also thanks for creating this reference manual and keeping it up to date :)
@Kristopher38 Thank you for reporting the issue and also for reviewing the changes. Really appreciated.
This issue is regarding Lua bytecode reference docs. In the section on OP_TEST and OP_TESTSET there is a line that states:
And a pseudocode:
But closely reading the Lua source for version 5.3.5, where the handling of OP_TEST and OP_TESTSET happens, we can conclude that the info in the docs is the wrong way around. Let me explain that with OP_TESTSET (the same applies to OP_TEST as well, just without R(A) = R(B) and the argument slots are different as stated in the docs). In the lvm.c the code for handling OP_TESTSET is as follows:
Now let me rewrite that in pseudocode (value in R(B) is coerced into a Lua boolean):
Which essentially means:
But the docs clearly state the opposite:
Paragraphs on OP_TEST and OP_TESTSET should be corrected to not be misleading.