lua-users home
lua-l archive

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


Gregor:

On Sun, Nov 18, 2018 at 9:51 AM Gregor Burghard <gburghard@gmx.de> wrote:
> here is a bug for Lua >= 5.3.0:
> When the finalizer method of a table resets the metatable of the same
> table, it will not be deleted after finalization. That means the table
> still exists and will be garbage collected again.

A more knowledgeable person may be give better details, but given
https://www.lua.org/manual/5.3/manual.html#2.5.1 says

<<You mark an object for finalization when you set its metatable and
the metatable has a field indexed by the string "__gc". >>

and a bit later..

<<Moreover, if the finalizer marks a finalizing object for
finalization again, its finalizer will be called again in the next
cycle where the object is unreachable>>

Seems like documented / expected behaviour to me ( a bit weird, but I
assume there is a reason, I can think of a couple of them ).

Francisco Olarte.