lua-users home
lua-l archive

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


Hi, I've noticed that the __call metamethod works with callable non
functions (other values with __call that aren't functions) in Lua 5.4.
This allows for __call to be a non function with a __call metamethod.
The value used in __call can create a loop, and Lua doesn't handle
this.

Example:
local t={}setmetatable(t,{__call=t})()

This causes an infinite loop in the latest Lua version (5.4.3).
Considering that __index and __newindex check if they have looped too
much (MAXTAGLOOP), it would make sense that __call should generate an
error if it has looped too much ("'__call' chain too long; possible
loop", similar to the __index and __newindex metamethods).