[#107867] Fwd: [ruby-cvs:91197] 8f59482f5d (master): add some tests for Unicode Version 14.0.0 — Martin J. Dürst <duerst@...>
To everybody taking care of continuous integration:
3 messages
2022/03/13
[#108090] [Ruby master Bug#18666] No rule to make target 'yaml/yaml.h', needed by 'api.o' — duerst <noreply@...>
Issue #18666 has been reported by duerst (Martin D端rst).
7 messages
2022/03/28
[#108117] [Ruby master Feature#18668] Merge `io-nonblock` gems into core — "Eregon (Benoit Daloze)" <noreply@...>
Issue #18668 has been reported by Eregon (Benoit Daloze).
22 messages
2022/03/30
[ruby-core:107894] [Ruby master Bug#18632] Struct.new wrongly treats a positional Hash as keyword arguments
From:
"jeremyevans0 (Jeremy Evans)" <noreply@...>
Date:
2022-03-14 16:01:15 UTC
List:
ruby-core #107894
Issue #18632 has been updated by jeremyevans0 (Jeremy Evans).
A lot of C methods will still treat positional hashes as keywords. I think only those that use `rb_scan_args`/`rb_scan_args_kw` will error if a regular hash is passed instead of keywords. For example, you can call `Kernel#raise` with a positional hash and it will treat the hash as keywords. This explains the behavior of the second Struct issue with the empty hash, which is treated as empty keywords and is ignored.
In short, this is not an issue specific to `Struct.new`. If we consider this a bug, we have to modify all C functions that use option hashes/keywords and do no use `rb_scan_args`/`rb_scan_args_kw`, and make them raise ArgumentError if passing a positional hash and not keywords. Even that wouldn't change the behavior of C function methods defined in external gems.
----------------------------------------
Bug #18632: Struct.new wrongly treats a positional Hash as keyword arguments
https://bugs.ruby-lang.org/issues/18632#change-96833
* Author: Eregon (Benoit Daloze)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux]
* Backport: 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
```
$ ruby -e 'Struct.new(:a, name: "b")'
-e:1:in `new': unknown keyword: :name (ArgumentError)
from -e:1:in `<main>'
^ expected
$ ruby -e 'Struct.new(:a, { name: "b" })'
-e:1:in `new': unknown keyword: :name (ArgumentError)
from -e:1:in `<main>'
^ wrong
```
It shouldn't be such an error for the 2nd command since it's a positional Hash.
It should be a TypeError, like when passing e.g. `nil` instead of the positional Hash.
Also:
```
$ ruby -e 'p Struct.new(:a, {}).members'
[:a]
```
But it should be an error to pass a positional Hash.
I think this is worth fixing, because it basically breaks the separation of positional and keyword arguments for this method.
Also Struct.new does take a keyword argument, `keyword_init: true`.
--
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>