diff options
author | Alan Wu <[email protected]> | 2023-09-07 14:56:07 -0400 |
---|---|---|
committer | Alan Wu <[email protected]> | 2023-09-12 11:25:07 -0400 |
commit | 39ee3e22bd3d071c1c283b6b8dbd1af413342fb1 (patch) | |
tree | da6a4f4c93d1887d477776b7f4575d5146f702e4 /test/ruby/test_lambda.rb | |
parent | b90272b3b661bd2fd557332028b8feb568b6b9df (diff) |
Make Kernel#lambda raise when given non-literal block
Previously, Kernel#lambda returned a non-lambda proc when given a
non-literal block and issued a warning under the `:deprecated` category.
With this change, Kernel#lambda will always return a lambda proc, if it
returns without raising.
Due to interactions with block passing optimizations, we previously had
two separate code paths for detecting whether Kernel#lambda got a
literal block. This change allows us to remove one path, the hack done
with rb_control_frame_t::block_code introduced in 85a337f for supporting
situations where Kernel#lambda returned a non-lambda proc.
[Feature #19777]
Co-authored-by: Takashi Kokubun <[email protected]>
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/8405
Diffstat (limited to 'test/ruby/test_lambda.rb')
-rw-r--r-- | test/ruby/test_lambda.rb | 26 |
1 files changed, 0 insertions, 26 deletions
diff --git a/test/ruby/test_lambda.rb b/test/ruby/test_lambda.rb index 9949fab8c7..7738034240 100644 --- a/test/ruby/test_lambda.rb +++ b/test/ruby/test_lambda.rb @@ -177,32 +177,6 @@ class TestLambdaParameters < Test::Unit::TestCase RUBY end - def pass_along(&block) - lambda(&block) - end - - def pass_along2(&block) - pass_along(&block) - end - - def test_create_non_lambda_for_proc_one_level - prev_warning, Warning[:deprecated] = Warning[:deprecated], false - f = pass_along {} - refute_predicate(f, :lambda?, '[Bug #15620]') - assert_nothing_raised(ArgumentError) { f.call(:extra_arg) } - ensure - Warning[:deprecated] = prev_warning - end - - def test_create_non_lambda_for_proc_two_levels - prev_warning, Warning[:deprecated] = Warning[:deprecated], false - f = pass_along2 {} - refute_predicate(f, :lambda?, '[Bug #15620]') - assert_nothing_raised(ArgumentError) { f.call(:extra_arg) } - ensure - Warning[:deprecated] = prev_warning - end - def test_instance_exec bug12568 = '[ruby-core:76300] [Bug #12568]' assert_nothing_raised(ArgumentError, bug12568) do |