summaryrefslogtreecommitdiff
path: root/spec/ruby/core/proc/lambda_spec.rb
diff options
context:
space:
mode:
authorAlan Wu <XrXr@users.noreply.github.com>2023-09-07 14:56:07 -0400
committerAlan Wu <XrXr@users.noreply.github.com>2023-09-12 11:25:07 -0400
commit39ee3e22bd3d071c1c283b6b8dbd1af413342fb1 (patch)
treeda6a4f4c93d1887d477776b7f4575d5146f702e4 /spec/ruby/core/proc/lambda_spec.rb
parentb90272b3b661bd2fd557332028b8feb568b6b9df (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 <takashikkbn@gmail.com>
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/8405
Diffstat (limited to 'spec/ruby/core/proc/lambda_spec.rb')
-rw-r--r--spec/ruby/core/proc/lambda_spec.rb8
1 files changed, 5 insertions, 3 deletions
diff --git a/spec/ruby/core/proc/lambda_spec.rb b/spec/ruby/core/proc/lambda_spec.rb
index b2d3f50350..5c3c38fc2a 100644
--- a/spec/ruby/core/proc/lambda_spec.rb
+++ b/spec/ruby/core/proc/lambda_spec.rb
@@ -14,9 +14,11 @@ describe "Proc#lambda?" do
Proc.new {}.lambda?.should be_false
end
- it "is preserved when passing a Proc with & to the lambda keyword" do
- suppress_warning {lambda(&->{})}.lambda?.should be_true
- suppress_warning {lambda(&proc{})}.lambda?.should be_false
+ ruby_version_is ""..."3.3" do
+ it "is preserved when passing a Proc with & to the lambda keyword" do
+ suppress_warning {lambda(&->{})}.lambda?.should be_true
+ suppress_warning {lambda(&proc{})}.lambda?.should be_false
+ end
end
it "is preserved when passing a Proc with & to the proc keyword" do