The return type for LEN is wrong if the __len metamethod for floats or integers is overwritten and the length from an array element from a ravi array is taken. As in the following example which errors with src/lvm.c:2428: luaV_execute: Assertion `((((rb))->tt_) == (((3) | ((1) << 4))))' failed.
debug.setmetatable(1, {
__len = function()
return "123"
end
})
local function f(x:integer[])
return #(x[1]) + 1
end
print(f(table.intarray(2)))
The return type for LEN is wrong if the
__len
metamethod for floats or integers is overwritten and the length from an array element from a ravi array is taken. As in the following example which errors withsrc/lvm.c:2428: luaV_execute: Assertion `((((rb))->tt_) == (((3) | ((1) << 4))))' failed.
The problem is that
luaK_exp2anyreg
can change theravi_type
if it is a load from an index as in the example above. The problematic place is https://github.com/dibyendumajumdar/ravi/blob/56a59a1f3117a8bc88206305b94398678de1bdff/src/lcode.c#L1270Following is the wrong bytecode with the unexpected
ADDII