From b549302d703cbb88cd44cadf009dc9d0bf5d918c Mon Sep 17 00:00:00 2001 From: Dibyendu Majumdar Date: Sun, 14 Feb 2021 20:11:58 +0000 Subject: [PATCH] issue #209 BNOT on any value other than integer should result in any type --- src/lcode.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lcode.c b/src/lcode.c index d5c1aa8..82f95e9 100644 --- a/src/lcode.c +++ b/src/lcode.c @@ -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) {