Issue #16853 has been updated by Eregon (Benoit Daloze).


FWIW I don't think it was "for Rails" but rather more use cases than that.

I want to note there is also both a performance cost and a semantics complication to only allowing Symbol keys.
If there is a call like `foo(**h)`, and `h` has both Symbol and non-Symbol keys, in <2.7 the Hash is "split" which I find extremely confusing and it's also slowing things down by always having to consider "there might be an extra positional argument".
The actual semantics of it are so complicated than you probably need multiple paragraphs just to describe them.
In short, I think most people agree it's a very bad idea to "split" keyword arguments like it was done in 2.0-2.6.
Maybe raising an error for non-Symbol keys would have made sense, but I don't think that would be any more compatible.

For `provides "some" => "strings", as: "name"`
Either the user understands there are two kind of arguments and does:
`provides({"some" => "strings"}, as: "name")`
Or they just see it as a configuration Hash and then the receiving method simply extracts `as` with `h.delete(:as)`.
On the syntactic side, `provides "some" => "strings", as: "name"` has always been a single Hash, relying on the splitting was IMHO very brittle, and it seems easy to workaround with just `def provides(h)`.

----------------------------------------
Bug #16853: calling bla(hash, **kw) with a string-based hash passes the strings into **kw (worked < 2.7)
https://bugs.ruby-lang.org/issues/16853#change-86428

* Author: sylvain.joyeux (Sylvain Joyeux)
* Status: Rejected
* Priority: Normal
* ruby -v: 2.7.1p83
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
The following code

~~~
def bla(hash = {}, **kw)
    puts "H: #{hash}"
    puts "K: #{kw}"
end

bla "some" => "string"
~~~

**silently** outputs the following (no warnings about deprecation of keyword parameters-from-hash)

~~~
H: {}
K: {"some"=>"string"}
~~~

While 2.6.5 (and versions before it) gave

~~~
H: {"some"=>"string"}
K: {}
~~~

I would expect "the warning" that started appearing in 2.7, and **definitely** not having strings in a keyword argument hash.



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>