[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: __gc metamethod and error()
- From: Andrew Gierth <andrew@...>
- Date: Tue, 01 Jan 2019 23:51:04 +0000
>>>>> "temp" == temp 213 qwe <temp213@gorodok.net> writes:
temp> setmetatable ({}, {__gc = function() print(1) error("error")
temp> print(2) end})
temp> It looks like at the end, garbage collector also collects
temp> something required by error() function first. So there is no
temp> error message from the code above, lua 5.3.5.
"at the end"? If you mean when calling lua_close on the state, then the
error() thrown is just ignored. __gc metamethods are always called via a
pcall; in normal operation any error caught by that pcall is rethrown,
interrupting the current round of finalization calls, but while closing
the state it would be pointless to propagate the error (propagate it to
what?) so it gets ignored instead.
--
Andrew.