Function Definitions
Foo = 4 Parameters, 1 Return Value
Bar = 4 Parameters, 2 Return Values
Edit:
After some searching, I found some documentation for lua version 5.4 specifically under 3.4.12 stating the following
"When a multires expression is used in a list of expressions without being the last element, or in a place where the syntax expects a single expression, Lua adjusts the result list of that expression to one element. As a particular case, the syntax expects a single expression inside a parenthesized expression; therefore, adding parentheses around a multires expression forces it to produce exactly one result."
https://www.lua.org/manual/5.4/manual.html#3.4.12
I am unsure now, if this is also part of the idea for 5.1, as I could not find any statements searching for the same kind of language being used above in the 5.1 documentation. If it is, then this is technically not a bug, and perhaps would turn into a suggestion. I am unsure if there is a good reason for the design.
Original:
In the example below, I am calling Foo, as the arguments, I call Bar twice. I believe what should happen is each call to Bar should push 2 numbers to the stack, before calling Foo, however only 3 numbers are pushed in total.
When converting this example to use a C++ side function (To make the debugging process easier for me), it appears that during the handling of the instruction "LOP_CALL" in lvmexecute.cpp, the nresults in the first call is set to 1, and -1 in the second. This appears to me as an incorrect generation of bytecode.
Effectively, the first call to Bar ends up pushing just one of the two numbers it is supposed to, and the second call to Bar actual push both numbers.
Luau Version: 0.642
Compile Options
Function Definitions Foo = 4 Parameters, 1 Return Value Bar = 4 Parameters, 2 Return Values
Edit: After some searching, I found some documentation for lua version 5.4 specifically under 3.4.12 stating the following "When a multires expression is used in a list of expressions without being the last element, or in a place where the syntax expects a single expression, Lua adjusts the result list of that expression to one element. As a particular case, the syntax expects a single expression inside a parenthesized expression; therefore, adding parentheses around a multires expression forces it to produce exactly one result." https://www.lua.org/manual/5.4/manual.html#3.4.12
I am unsure now, if this is also part of the idea for 5.1, as I could not find any statements searching for the same kind of language being used above in the 5.1 documentation. If it is, then this is technically not a bug, and perhaps would turn into a suggestion. I am unsure if there is a good reason for the design.
Original: In the example below, I am calling Foo, as the arguments, I call Bar twice. I believe what should happen is each call to Bar should push 2 numbers to the stack, before calling Foo, however only 3 numbers are pushed in total.
When converting this example to use a C++ side function (To make the debugging process easier for me), it appears that during the handling of the instruction "LOP_CALL" in lvmexecute.cpp, the nresults in the first call is set to 1, and -1 in the second. This appears to me as an incorrect generation of bytecode.
Effectively, the first call to Bar ends up pushing just one of the two numbers it is supposed to, and the second call to Bar actual push both numbers.
Example Code
Example Output
Expected Output