diff options
author | Kevin Newton <[email protected]> | 2024-06-06 14:44:29 -0400 |
---|---|---|
committer | Kevin Newton <[email protected]> | 2024-06-06 16:29:50 -0400 |
commit | cbc83c4a9221110a94c670d07ed5b23548202cf2 (patch) | |
tree | 54c3769513109117fb17578a360d27d96fe7238d /spec/ruby/language/lambda_spec.rb | |
parent | eb46b0924f916191a79d59b3ebc1d24a945e2171 (diff) |
Remove circular parameter syntax error
https://bugs.ruby-lang.org/issues/20478
Diffstat (limited to 'spec/ruby/language/lambda_spec.rb')
-rw-r--r-- | spec/ruby/language/lambda_spec.rb | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/spec/ruby/language/lambda_spec.rb b/spec/ruby/language/lambda_spec.rb index 3ab3569ebe..ed5a1c69e8 100644 --- a/spec/ruby/language/lambda_spec.rb +++ b/spec/ruby/language/lambda_spec.rb @@ -263,18 +263,21 @@ describe "A lambda literal -> () { }" do end describe "with circular optional argument reference" do - it "raises a SyntaxError if using an existing local with the same name as the argument" do - a = 1 - -> { - @proc = eval "-> (a=a) { a }" - }.should raise_error(SyntaxError) + ruby_version_is ""..."3.4" do + it "raises a SyntaxError if using the argument in its default value" do + a = 1 + -> { + eval "-> (a=a) { a }" + }.should raise_error(SyntaxError) + end end - it "raises a SyntaxError if there is an existing method with the same name as the argument" do - def a; 1; end - -> { - @proc = eval "-> (a=a) { a }" - }.should raise_error(SyntaxError) + ruby_version_is "3.4" do + it "is nil if using the argument in its default value" do + -> { + eval "-> (a=a) { a }.call" + }.call.should == nil + end end it "calls an existing method with the same name as the argument if explicitly using ()" do |