mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Make circular argument reference a SyntaxError instead of a warning
Fixes [Bug #10314]
This commit is contained in:
parent
fdfb5100b9
commit
0162e7e647
Notes:
git
2019-10-18 01:32:31 +09:00
5 changed files with 99 additions and 54 deletions
|
@ -177,17 +177,32 @@ describe "An instance method with a default argument" do
|
|||
foo(2,3,3).should == [2,3,[3]]
|
||||
end
|
||||
|
||||
it "shadows an existing method with the same name as the local" do
|
||||
def bar
|
||||
1
|
||||
ruby_version_is ''...'2.7' do
|
||||
it "warns and uses a nil value when there is an existing local method with same name" do
|
||||
def bar
|
||||
1
|
||||
end
|
||||
-> {
|
||||
eval "def foo(bar = bar)
|
||||
bar
|
||||
end"
|
||||
}.should complain(/circular argument reference/)
|
||||
foo.should == nil
|
||||
foo(2).should == 2
|
||||
end
|
||||
end
|
||||
|
||||
ruby_version_is '2.7' do
|
||||
it "raises a syntaxError an existing method with the same name as the local variable" do
|
||||
def bar
|
||||
1
|
||||
end
|
||||
-> {
|
||||
eval "def foo(bar = bar)
|
||||
bar
|
||||
end"
|
||||
}.should raise_error(SyntaxError)
|
||||
end
|
||||
-> {
|
||||
eval "def foo(bar = bar)
|
||||
bar
|
||||
end"
|
||||
}.should complain(/circular argument reference/)
|
||||
foo.should == nil
|
||||
foo(2).should == 2
|
||||
end
|
||||
|
||||
it "calls a method with the same name as the local when explicitly using ()" do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue