Skip to content

Commit

Permalink
issue #210 LEN on any value other than array or table should be any type
Browse files Browse the repository at this point in the history
  • Loading branch information
dibyendumajumdar committed Feb 14, 2021
1 parent b549302 commit 927ddbf
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/lcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 927ddbf

Please sign in to comment.