From: mame@... Date: 2018-12-24T09:08:34+00:00 Subject: [ruby-core:90694] [Ruby trunk Bug#15457][Closed] Weird behaviour when having multiple arguments of same name and splat operator Issue #15457 has been updated by mame (Yusuke Endoh). Status changed from Open to Closed Thank you. This is duplicate of #14611. The behavior has been changed in trunk (and 2.6). ``` $ cat bug.rb def test(_a, b, *_a) pp _a pp b end test(*%W{a b c d e}) $ ./local/bin/ruby -v bug.rb ruby 2.6.0dev (2018-12-24 trunk 66525) [x86_64-linux] "a" "b" ``` #14611 is marked as backport required. Please wait. ---------------------------------------- Bug #15457: Weird behaviour when having multiple arguments of same name and splat operator https://bugs.ruby-lang.org/issues/15457#change-75869 * Author: graywolf (Gray Wolf) * Status: Closed * Priority: Normal * Assignee: * Target version: * ruby -v: 2.5.3 * Backport: 2.4: UNKNOWN, 2.5: UNKNOWN ---------------------------------------- When multiple arguments of the same name are provided and last one of them has splat operator, everything gets weird. ``` + $ cat bug.rb def test(_a, b, *_a) pp _a pp b end test(*%W{a b c d e}) + $ RUBYOPT=-rpry rvm 2.5.3 do ruby bug.rb ["c", "d", "e"] nil + $ RUBYOPT=-rpry rvm 2.4.5 do ruby bug.rb ["c", "d", "e"] nil + $ RUBYOPT=-rpry rvm 2.3.8 do ruby bug.rb ["c", "d", "e"] nil ``` At least it's consistent across supported ruby versions, but I have no idea what is going on. I get why `_a` is `%w{c d e}`, that makes sense. But why is `b` `nil`? That makes no sense at all. It looks to me like an edge case when having multiple arguments of the same name and one of them (last one?) having splat operator. -- https://bugs.ruby-lang.org/ Unsubscribe: