Skip to content

Commit

Permalink
issue #209 BNOT on any value other than integer should result in any …
Browse files Browse the repository at this point in the history
…type
  • Loading branch information
dibyendumajumdar committed Feb 14, 2021
1 parent 56a59a1 commit b549302
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/lcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1269,8 +1269,12 @@ static void codeunexpval (FuncState *fs, OpCode op, expdesc *e, int line) {
ravitype_t e_type = e->ravi_type;
int r = luaK_exp2anyreg(fs, e); /* opcodes operate only on registers */
freeexp(fs, e);
if (op == OP_BNOT && e->ravi_type == RAVI_TNUMINT)
op = OP_RAVI_BNOT_I;
if (op == OP_BNOT) {
if (e->ravi_type == RAVI_TNUMINT)
op = OP_RAVI_BNOT_I;
else
e->ravi_type = RAVI_TANY; /* Since it could be a float*/
}
e->u.info = luaK_codeABC(fs, op, 0, r, 0); /* generate opcode */
e->k = VRELOCABLE; /* all those operations are relocatable */
if (op == OP_LEN) {
Expand Down

0 comments on commit b549302

Please sign in to comment.