From: acct.colinhart@... Date: 2021-03-17T20:08:38+00:00 Subject: [ruby-core:102907] [Ruby master Bug#17727] Unexpected syntax error when passing hash to **arg with kwarg Issue #17727 has been reported by colintherobot (Colin Hart). ---------------------------------------- Bug #17727: Unexpected syntax error when passing hash to **arg with kwarg https://bugs.ruby-lang.org/issues/17727 * Author: colintherobot (Colin Hart) * Status: Open * Priority: Normal * ruby -v: ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin19] * Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN ---------------------------------------- Given a method that takes a kwarg and **arg ``` ruby def foo(a:, **b) [a,b] end ``` If you call this method without deconstructing the hash passed to the second argument first it throws an error that that I thought was maybe just an unhandled case. Would expect a message indicating you need to deconstruct the hash first. ``` ruby foo(a: '1', {b: 2}) SyntaxError: unexpected ')', expecting => foo(a: '1', {b: 2}) ^ ``` Passing case when you deconstruct the hash first ``` ruby foo(a: '1', **{b: 2}) => ["1", {:b=>2}] ``` But wondering if there's something else going on cause you get a different error when defining this case on multiple lines. In fact, if you're trying to run this in the repl it won't even let you complete the method call. from repl ``` ruby foo( a: '1', {b: 2} SyntaxError: unexpected '\n', expecting => ``` passing case ``` ruby foo( a: '1', **{b:1} ) => ["1", {:b=>1}] ``` Attached is a ruby script to reproduce the above cases. ---Files-------------------------------- kwarg_bug.rb (291 Bytes) -- https://bugs.ruby-lang.org/ Unsubscribe: