Closed maximecb closed 2 years ago
@jhawthorn Am I wrong about this? Can an arbitrary class redefine nil?
to return true
? 🤔
Unfortunately, yes, arbitrary classes can redefine nil?
and it is (IMO horrifyingly) done somewhat regularly in practice as well (here's one of many examples)
Welp, this is awful.
I've encountered an instance where the
opt_nil_p
instruction generates the following machine code:It seems to me that if we know that the value is not an immediate, then we know it can't be
nil
, and we could avoid the guard known class check 🤔This might be slightly tricky since we currently delegate to
gen_opt_send_without_block
to handle all the cases.