Skip to content

Commit

Permalink
issue #210 bug in recognizing the type change when an expression of V…
Browse files Browse the repository at this point in the history
…INDEXED type gets resolved
  • Loading branch information
dibyendumajumdar committed Feb 15, 2021
1 parent fe7c76f commit 9ced7e2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1266,8 +1266,8 @@ static int constfolding (FuncState *fs, int op, expdesc *e1,
** Expression to produce final result will be encoded in 'e'.
*/
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 */
ravitype_t e_type = e->ravi_type;
freeexp(fs, e);
if (op == OP_BNOT) {
if (e->ravi_type == RAVI_TNUMINT)
Expand Down
8 changes: 8 additions & 0 deletions tests/language/ravi_tests1.ravi
Original file line number Diff line number Diff line change
Expand Up @@ -1811,6 +1811,14 @@ end
check(x, 'TOIARRAY', 'IARRAY_GET', 'LEN', 'ADD', 'RETURN', 'RETURN')
print 'Test 85 OK'

-- Test that #() applied to non integer type produces any type
-- issue #210
function x(x:integer[])
return #x[1]+1
end
check(x, 'TOIARRAY', 'IARRAY_GET', 'LEN', 'ADD', 'RETURN', 'RETURN')
print 'Test 86 OK'


for k,v in pairs(opcodes_coverage)
do
Expand Down

0 comments on commit 9ced7e2

Please sign in to comment.