Project

General

Profile

Bug #16519

Updated by Eregon (Benoit Daloze) almost 5 years ago

This happens on `master`: 

 ``` 
 $ ruby -ve 'ruby2_keywords def flag(*a); a.last; end; pp [flag(**{})]' 
 ruby 2.8.0dev (2020-01-21T13:45:10Z master 5798d35ff6) [x86_64-linux] 
 [nil] 
 ``` 

 Of course it should be `[{}]`, as it is for `pp [{}]`. 

 On 2.7.0 it warns (should be fixed, it's valid to `pp` a flagged Hash): 
 ``` 
 $ ruby -ve 'ruby2_keywords def flag(*a); a.last; end; pp [flag(**{})]' 
 ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux] 
 [/home/eregon/.rubies/ruby-2.7.0/lib/ruby/2.7.0/pp.rb:226: warning: Passing the keyword argument as the last hash parameter is deprecated 
 /home/eregon/.rubies/ruby-2.7.0/lib/ruby/2.7.0/pp.rb:334: warning: The called method is defined here 
 {}] 
 ``` 

 The warning being in the middle of the output is a fun fact here. 
 Lines it refers to (still the same on current master): 
 https://github.com/ruby/ruby/blob/v2_7_0/lib/pp.rb#L226 
 https://github.com/ruby/ruby/blob/v2_7_0/lib/pp.rb#L334 

 This is very confusing as it can happen during `test-all` and then show output such as: 
 ``` 
 <[{:a=>1}]> expected but was 
 <[{:a=>1}, nil]>. 
 ``` 
 when the reality is (can be verified with `p` before the `assert_equal`): 
 ``` 
 <[{:a=>1}]> expected but was 
 <[{:a=>1}, {}]>. 
 ```

Back