From: merch-redmine@... Date: 2020-01-24T21:36:54+00:00 Subject: [ruby-core:96995] [Ruby master Bug#16560] Proc autosplats first argument if called with one argument and empty keyword splat Issue #16560 has been updated by jeremyevans0 (Jeremy Evans). Dan0042 (Daniel DeLorme) wrote: > Although imho that would be the expected behavior in 3.0, and in 2.7 it should be a warning with the same behavior as 2.6. No, in 2.7 empty keyword splats are removed in most cases without warning, that is unrelated to proc autosplatting: ```ruby def a(b, c=0) [b, c] end h = {} a([1, 2], **h) # => [[1, 2], {}] # 2.6 # => [[1, 2], 0] # 2.7 ``` The cases where they aren't removed in 2.7: * Empty keyword splat is needed for mandatory positional argument (issues a warning) * ruby2_keywords methods so that a final positional hash before keywords is not treated as keywords by target method ---------------------------------------- Bug #16560: Proc autosplats first argument if called with one argument and empty keyword splat https://bugs.ruby-lang.org/issues/16560#change-84053 * Author: Dan0042 (Daniel DeLorme) * Status: Closed * Priority: Normal * Assignee: * Target version: * ruby -v: * Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: REQUIRED ---------------------------------------- While working on understanding the vm_args.c code via refactoring, I found the following: ```ruby b = proc{ |a,b=0| [a,b] } h = {k:42} b.call([1,2,3],**h) #=> [[1, 2, 3], {:k=>42}] h = {} b.call([1,2,3],**h) #=> [1, 2] (in 2.7) #=> [[1, 2, 3], {}] (in 2.6) ``` Since the result is different from 2.6 I think this is a bug, especially since the result in 2.7 is so different based on being an empty or non-empty splat. In my refactoring branch I'm solving this by moving the `args_check_block_arg0` check before the `ignore_keyword_hash_p` check, but that doesn't look so easy in master. -- https://bugs.ruby-lang.org/ Unsubscribe: