[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Recursive __call with callable non functions loops forever
- From: Halalaluyafail3 <luigighiron@...>
- Date: Tue, 3 Aug 2021 19:54:56 -0400
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).