Project

General

Profile

Bug #12568

Updated by naruse (Yui NARUSE) almost 4 years ago

From Ruby 2.2 to trunk, it wrongly raise ArgumentError as follows: 

 Sample code: 

 
 ```ruby 
 instance_exec([1,2,3]){|a| p a} 
 instance_exec([1,2,3]){|a=[]| p a} 
 instance_exec([1,2,3], &->(a){ p a }) 
 ->(a=[]){ p a }.to_proc.call([1,2,3]) 
 instance_exec([1,2,3], &->(a=[]){ p a }) 
 ``` 

 Expected result: 

 
 ``` 
 [1, 2, 3] 
 [1, 2, 3] 
 [1, 2, 3] 
 [1, 2, 3] 
 [1, 2, 3] 
 ``` 

 Actual result: 

 
 ``` 
 [1, 2, 3] 
 [1, 2, 3] 
 [1, 2, 3] 
 [1, 2, 3] 
 test.rb:7:in `block in <main>': wrong number of arguments (given 3, expected 0..1) (ArgumentError) 
	 from test.rb:7:in `instance_exec' 
	 from test.rb:7:in `<main>' 
 ``` 

 This issue affect https://github.com/rails/rails/pull/25699

Back