diff options
author | Yusuke Endoh <[email protected]> | 2025-01-20 17:41:08 +0900 |
---|---|---|
committer | Yusuke Endoh <[email protected]> | 2025-02-18 16:23:24 +0900 |
commit | 993fd96ce6bb763e08207bb3d53824d5d46d07a4 (patch) | |
tree | 1794e9e8411c5bfd139d0b730642c8678e9bf07f /spec/ruby | |
parent | 6d75599a1aade9f8081d0691a9da1e62a5428e95 (diff) |
reject numbered parameters from Binding#local_variables
Also, Binding#local_variable_get and #local_variable_set rejects an
access to numbered parameters.
[Bug #20965] [Bug #21049]
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/12746
Diffstat (limited to 'spec/ruby')
-rw-r--r-- | spec/ruby/language/numbered_parameters_spec.rb | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/spec/ruby/language/numbered_parameters_spec.rb b/spec/ruby/language/numbered_parameters_spec.rb index 06f9948c58..a3153d3cc6 100644 --- a/spec/ruby/language/numbered_parameters_spec.rb +++ b/spec/ruby/language/numbered_parameters_spec.rb @@ -90,9 +90,18 @@ describe "Numbered parameters" do proc { _2 }.parameters.should == [[:opt, :_1], [:opt, :_2]] end - it "affects binding local variables" do - -> { _1; binding.local_variables }.call("a").should == [:_1] - -> { _2; binding.local_variables }.call("a", "b").should == [:_1, :_2] + ruby_version_is "".."3.4" do + it "affects binding local variables" do + -> { _1; binding.local_variables }.call("a").should == [:_1] + -> { _2; binding.local_variables }.call("a", "b").should == [:_1, :_2] + end + end + + ruby_version_is "3.5" do + it "does not affect binding local variables" do + -> { _1; binding.local_variables }.call("a").should == [] + -> { _2; binding.local_variables }.call("a", "b").should == [] + end end it "does not work in methods" do |