mirror of
https://github.com/lua/lua
synced 2025-02-11 18:54:00 +03:00
Fixed bug when yiedling inside OP_ADDK opcode
The family of opcodes OP_ADDK (arithmetic operators with K constant) were not being handled in 'luaV_finishOp', which completes their task after an yield.
This commit is contained in:
parent
be78aeae4c
commit
3df5624ff4
3
lvm.c
3
lvm.c
@ -720,6 +720,9 @@ void luaV_finishOp (lua_State *L) {
|
||||
case OP_ADDI: case OP_SUBI:
|
||||
case OP_MULI: case OP_DIVI: case OP_IDIVI:
|
||||
case OP_MODI: case OP_POWI:
|
||||
case OP_ADDK: case OP_SUBK:
|
||||
case OP_MULK: case OP_DIVK: case OP_IDIVK:
|
||||
case OP_MODK: case OP_POWK:
|
||||
case OP_ADD: case OP_SUB:
|
||||
case OP_MUL: case OP_DIV: case OP_IDIV:
|
||||
case OP_BANDK: case OP_BORK: case OP_BXORK:
|
||||
|
@ -724,6 +724,17 @@ assert(run(function () return a / b end, {"div"}) == 10/12)
|
||||
assert(run(function () return a % b end, {"mod"}) == 10)
|
||||
assert(run(function () return a // b end, {"idiv"}) == 0)
|
||||
|
||||
-- repeat tests with larger constants (to use 'K' opcodes)
|
||||
local a1000 = new(1000)
|
||||
|
||||
assert(run(function () return a1000 + 1000 end, {"add"}) == 2000)
|
||||
assert(run(function () return a1000 - 25000 end, {"sub"}) == -24000)
|
||||
assert(run(function () return 2000 * a end, {"mul"}) == 20000)
|
||||
assert(run(function () return a1000 / 1000 end, {"div"}) == 1)
|
||||
assert(run(function () return a1000 % 600 end, {"mod"}) == 400)
|
||||
assert(run(function () return a1000 // 500 end, {"idiv"}) == 2)
|
||||
|
||||
|
||||
|
||||
assert(run(function () return a % b end, {"mod"}) == 10)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user