lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi everyone (first time posting here...),

while experimenting with adding accessor functions to Lua I discovered a
crash bug in v5.1.4 of the VM:

=== begin code===
    local grandparent = {}
    grandparent.__newindex = function(s,_,_) print(s) end

    local parent = {}
    parent.__newindex = parent
    setmetatable(parent, grandparent)

    local child = setmetatable({}, parent)
    child.foo = _      --> CRASH!
=== end code ===

I've tracked down the cause of this bug and created a patch to fix it, you
can find it at the end of my article on accessors:

http://www.ppl-pilot.com/Lua/LuaAccessors.html

Cheers,

Mark Feldman