The #lambda method normally returns a lambda:
lambda {}.lambda?
#=> true
Kernel.send {}.lambda?
#=> true
Kernel.__send__ {}.lambda?
#=> true
In CRuby and JRuby, publicly sending #lambda to Kernel also results in a lambda, but not-so in TruffleRuby:
Kernel.public_send(:lambda) {}.lambda?
#=> false
This seems related to the discussion in #12.
Thank you for the bug report. Creating lambdas has to take note of whether the block is a literal, and determining that depends on knowing the caller, and ignoring send when it comes between the lambda method and the real caller. We correctly skipped send and __send__, but public_send is a different method and wasn't being skipped correctly.
I'll submit a fix for this.
This was fixed in ccdf00533257513278a8c78772c7ae84d7ea7261 and will be available in our next release. Thanks for comprehensive bug report!
Most helpful comment
Thank you for the bug report. Creating lambdas has to take note of whether the block is a literal, and determining that depends on knowing the caller, and ignoring
sendwhen it comes between thelambdamethod and the real caller. We correctly skippedsendand__send__, butpublic_sendis a different method and wasn't being skipped correctly.I'll submit a fix for this.