Bladeren bron

Fixed missing case in 'luaV_finishOp'

A metamethod call like '1 << a' was not being properly resumed
if it got yielded.
Roberto Ierusalimschy 6 jaren geleden
bovenliggende
commit
643188d6e5
2 gewijzigde bestanden met toevoegingen van 7 en 1 verwijderingen
  1. 1 1
      lvm.c
  2. 6 0
      testes/coroutine.lua

+ 1 - 1
lvm.c

@@ -727,7 +727,7 @@ void luaV_finishOp (lua_State *L) {
     case OP_MUL: case OP_DIV: case OP_IDIV:
     case OP_BANDK: case OP_BORK: case OP_BXORK:
     case OP_BAND: case OP_BOR: case OP_BXOR:
-    case OP_SHRI: case OP_SHL: case OP_SHR:
+    case OP_SHLI: case OP_SHRI: case OP_SHL: case OP_SHR:
     case OP_MOD: case OP_POW:
     case OP_UNM: case OP_BNOT: case OP_LEN:
     case OP_GETTABUP: case OP_GETTABLE: case OP_GETI:

+ 6 - 0
testes/coroutine.lua

@@ -747,6 +747,12 @@ assert(run(function () return a >> b end, {"shr"}) == 10 >> 12)
 assert(run(function () return 10 & b end, {"band"}) == 10 & 12)
 assert(run(function () return a | 2 end, {"bor"}) == 10 | 2)
 assert(run(function () return a ~ 2 end, {"bxor"}) == 10 ~ 2)
+assert(run(function () return a >> 2 end, {"shr"}) == 10 >> 2)
+assert(run(function () return 1 >> a end, {"shr"}) == 1 >> 10)
+assert(run(function () return a << 2 end, {"shl"}) == 10 << 2)
+assert(run(function () return 1 << a end, {"shl"}) == 1 << 10)
+assert(run(function () return a ~ 2 end, {"bxor"}) == 10 ~ 2)
+
 
 assert(run(function () return a..b end, {"concat"}) == "1012")