There appears to be an issue with metatables. The following prints the output 3 and 5 in Lua 5.3. However, in Luerl it crashes with (FunctionClauseError) no function clause matching in :luerl_heap.raw_set_table_key/4.
MyArray = {}
MyArray.__index = MyArray
function MyArray.new(array)
local self = setmetatable({}, MyArray)
self.array = array
return self
end
function MyArray:__index(key)
return self.array[key]
end
function MyArray:__newindex(key, value)
if type(key) == "number" then
self.array[key] = value
else
rawset(self, key, value)
end
end
local seq = MyArray.new({1,2,3,4})
print(seq[3])
seq[3] = 5
print(seq[3])
Note, this behaviour was discovered by @guyjbrown.
There appears to be an issue with metatables. The following prints the output 3 and 5 in Lua 5.3. However, in Luerl it crashes with
(FunctionClauseError) no function clause matching in :luerl_heap.raw_set_table_key/4
.Note, this behaviour was discovered by @guyjbrown.