From 927ddbf6a0220225b81d345387499ef54bbaafe3 Mon Sep 17 00:00:00 2001 From: Dibyendu Majumdar Date: Sun, 14 Feb 2021 20:17:30 +0000 Subject: [PATCH] issue #210 LEN on any value other than array or table should be any type --- src/lcode.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/lcode.c b/src/lcode.c index 82f95e9..8c3565d 100644 --- a/src/lcode.c +++ b/src/lcode.c @@ -1278,13 +1278,16 @@ static void codeunexpval (FuncState *fs, OpCode op, expdesc *e, int line) { e->u.info = luaK_codeABC(fs, op, 0, r, 0); /* generate opcode */ e->k = VRELOCABLE; /* all those operations are relocatable */ if (op == OP_LEN) { - if (e_type == RAVI_TARRAYINT || e_type == RAVI_TARRAYFLT) + if (e_type == RAVI_TARRAYINT || e_type == RAVI_TARRAYFLT) e->ravi_type = RAVI_TNUMINT; - else if (e_type == RAVI_TTABLE) { - luaK_exp2anyreg(fs, e); - luaK_codeABC(fs, OP_RAVI_TOINT, e->u.info, 0, 0); - e->ravi_type = RAVI_TNUMINT; - } + else if (e_type == RAVI_TTABLE) { + luaK_exp2anyreg(fs, e); + luaK_codeABC(fs, OP_RAVI_TOINT, e->u.info, 0, 0); + e->ravi_type = RAVI_TNUMINT; + } + else { + e->ravi_type = RAVI_TANY; + } } luaK_fixline(fs, line); }