[#98098] [Ruby master Feature#16824] Follow RubyGems naming conventions for the stdlib — shannonskipper@...

Issue #16824 has been reported by shan (Shannon Skipper).

14 messages 2020/05/01

[#98147] [Ruby master Feature#16832] Use #name rather than #inspect to build "uninitialized constant" error messages — jean.boussier@...

Issue #16832 has been reported by byroot (Jean Boussier).

20 messages 2020/05/06

[#98174] [Ruby master Bug#16837] Can we make Ruby 3.0 as fast as Ruby 2.7 with the new assertions? — takashikkbn@...

Issue #16837 has been reported by k0kubun (Takashi Kokubun).

10 messages 2020/05/07

[#98241] [Ruby master Bug#16845] Building Ruby with old existing system Ruby results in make error with ./tool/file2lastrev.rb — erik@...

Issue #16845 has been reported by ErikSwan (Erik Swan).

7 messages 2020/05/09

[#98256] [Ruby master Feature#16847] Cache instruction sequences by default — jean.boussier@...

Issue #16847 has been reported by byroot (Jean Boussier).

16 messages 2020/05/11

[#98257] [Ruby master Feature#16848] Allow callables in $LOAD_PATH — jean.boussier@...

Issue #16848 has been reported by byroot (Jean Boussier).

27 messages 2020/05/11

[#98318] [Ruby master Bug#16853] calling bla(hash, **kw) with a string-based hash passes the strings into **kw (worked < 2.7) — sylvain.joyeux@...4x.org

Issue #16853 has been reported by sylvain.joyeux (Sylvain Joyeux).

12 messages 2020/05/13

[#98355] [Ruby master Bug#16889] TracePoint.enable { ... } also activates the TracePoint for other threads, even outside the block — eregontp@...

Issue #16889 has been reported by Eregon (Benoit Daloze).

16 messages 2020/05/14

[#98363] [Ruby master Feature#16891] Restore Positional Argument to Keyword Conversion — merch-redmine@...

Issue #16891 has been reported by jeremyevans0 (Jeremy Evans).

23 messages 2020/05/14

[#98371] [Ruby master Feature#16894] Integer division for Ruby 3 — andrew@...

Issue #16894 has been reported by ankane (Andrew Kane).

18 messages 2020/05/15

[#98391] [Ruby master Bug#16896] MakeMakefile methods should be private — eregontp@...

Issue #16896 has been reported by Eregon (Benoit Daloze).

10 messages 2020/05/15

[#98396] [Ruby master Feature#16897] Can a Ruby 3.0 compatible general purpose memoizer be written in such a way that it matches Ruby 2 performance? — sam.saffron@...

Issue #16897 has been reported by sam.saffron (Sam Saffron).

25 messages 2020/05/16

[#98453] [Ruby master Bug#16904] rubygems: psych: superclass mismatch for class Mark (TypeError) — jaruga@...

Issue #16904 has been reported by jaruga (Jun Aruga).

18 messages 2020/05/20

[#98486] [Ruby master Bug#16908] Strange behaviour of Hash#shift when used with `default_proc`. — samuel@...

Issue #16908 has been reported by ioquatix (Samuel Williams).

14 messages 2020/05/23

[#98569] [Ruby master Bug#16921] s390x: ramdom test failures for timeout or segmentation fault — jaruga@...

Issue #16921 has been reported by jaruga (Jun Aruga).

9 messages 2020/05/29

[#98599] [Ruby master Bug#16926] Kernel#require does not load a feature twice when $LOAD_PATH has been modified spec fails only on 2.7 — eregontp@...

Issue #16926 has been reported by Eregon (Benoit Daloze).

12 messages 2020/05/31

[ruby-core:98387] [Ruby master Bug#16853] calling bla(hash, **kw) with a string-based hash passes the strings into **kw (worked < 2.7)

From: mame@...
Date: 2020-05-15 14:41:10 UTC
List: ruby-core #98387
Issue #16853 has been updated by mame (Yusuke Endoh).


@sylvain.joyeux

Hi!  I read [your comment in the discuss RubyOnRails](https://discuss.rubyonrails.org/t/new-2-7-3-0-keyword-argument-pain-point/74980/13).  I'm sorry for bothering you about this change.  Let me explain a bit.


This change was introduced into 2.7 because the old behavior was unintentional.  In fact, Ruby 2.0.0-p0 was the same as the current (2.7) behavior.

```
$ ./bin/ruby-2.0.0-p0 -ve '
def provides(h = {}, **kw)
  p kw
end

provides("some" => "strings", as: "name")
'
ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-linux]
{"some"=>"strings", :as=>"name"}
```

But the behavior was changed to reject non-symbol keys, and it was done without matz's confirmation.  So in a sense, this is a bug fix.

That being said, we don't change such a long-working behavior without a reason.  The reason why it was changed is because there are some methods that want to accept both symbol and non-symbol keys: `where(id: 42)` and `where("table.id" => 42)`.  This will not work in 3.0 if keyword arguments are completely separated from positional ones.  So, non-symbol keys were allowed to keyword arguments.


BTW, in that forum, you said "adding a keyword splat will break code".  This is true, even without this 2.7 change.  Please consider:

```
def m(mapping = {}); mapping; end

m(k: 1) #=> {:k=>1}
```

and if you add `**kw`,

```
def m(mapping = {}, **kw); mapping; end

m(k: 1) #=> {} # changed
```

Fixing this issue was (one of) the original motivation of 3.0 keyword arguments (#14183): consistently passing `k: 1` to keywords, and `{ k: 1 }` to positional.  This is very simple and completely solves the ambiguity.  But unfortunately, it turned out too breaking.  We decided to continue allowing the automatic conversion from keywords to positional.  I want to solve the ambiguity in future, but it is very tough.


To know your pain point precisely, I'd like to ask you a question: can you manually separate non-symbol keys?

```
def provides(h = {}, **kw)
  kw.each {|k, v| h[k] = v if k.is_a?(Symbol) }

  ...main code...
end
```

I think this code works perfectly even in 2.6.  I'm sorry for asking you to change your code, but if we change anything, anyone must pay a cost.  (No change require no cost, but I believe that it means the death of the language.)  To minimize the sum of costs, I'd like to know how pain your pain point is.

Again, I'm really sorry for bothering you, and thank you for taking time for this issue.

----------------------------------------
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-85656

* 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>

In This Thread