Closed ddavness closed 4 years ago
This seems like a real edge case that's going to add some performance overhead. Can you give me a real world example that caused this issue to occur for you?
I'm currently writing an http library and the objects/classes/whatever represented try to emulate the behavior of userdatas like Vector3
(where indexing non-existant members will immediately throw) via a metatable that throws.
However, unlike the actual userdatas where type(object) == "userdata"
, it's still a table and goes through the first check (but fails the second because it throws).
I admit that there might be better solutions to this issue rather than employing pcall()
right away (but pcall()
is hands down the easiest to implement).
I tried employing rawget
but that will break the whole module. On the other hand, is the performance overhead of a pcall()
really that big/noticeable of an issue?
Some tables might have strict metatables that error if a non-existant member is indexed, causing the chain to fail.
Minimal reproduction sample: