Truffleruby: Publicly sending #lambda to Kernel doesn't result in a lambda

Created on 11 Sep 2018  路  2Comments  路  Source: oracle/truffleruby

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.

bug

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 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.

All 2 comments

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!

Was this page helpful?
0 / 5 - 0 ratings