ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:124594] [Ruby Bug#21844] Inconsistent ArgumentError message for Data::define.new
@ 2026-01-20  4:59 jnchito (Junichi Ito) via ruby-core
  2026-01-20  5:42 ` [ruby-core:124595] " nobu (Nobuyoshi Nakada) via ruby-core
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: jnchito (Junichi Ito) via ruby-core @ 2026-01-20  4:59 UTC (permalink / raw)
  To: ruby-core; +Cc: jnchito (Junichi Ito)

Issue #21844 has been reported by jnchito (Junichi Ito).

----------------------------------------
Bug #21844: Inconsistent ArgumentError message for Data::define.new
https://bugs.ruby-lang.org/issues/21844

* Author: jnchito (Junichi Ito)
* Status: Open
* ruby -v: ruby 4.0.1 (2026-01-13 revision e04267a14b) +PRISM [arm64-darwin25]
* Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN
----------------------------------------
The code below shows `Data::define.new` treats symbol and string keys equivalently:

``` ruby
C = Data.define(:a, :b)

C.new(a: 1, b: 1)
#=> #<data C a=1, b=1>

C.new('a' => 1, 'b' => 1)
#=> #<data C a=1, b=1>
```

But it acts differently when detecting missing keywords:

```ruby
C.new(a: 1)
#=> 'Data#initialize': missing keyword: :b (ArgumentError)
C.new('a' => 1)
#=> 'Data#initialize': missing keywords: :a, :b (ArgumentError)
```

I feel it should work like this:

```ruby
C.new('a' => 1)
#=> 'Data#initialize': missing keyword: :b (ArgumentError)
```

I created a PR to fix it:

https://github.com/ruby/ruby/pull/15910



-- 
https://bugs.ruby-lang.org/
______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [ruby-core:124595] [Ruby Bug#21844] Inconsistent ArgumentError message for Data::define.new
  2026-01-20  4:59 [ruby-core:124594] [Ruby Bug#21844] Inconsistent ArgumentError message for Data::define.new jnchito (Junichi Ito) via ruby-core
@ 2026-01-20  5:42 ` nobu (Nobuyoshi Nakada) via ruby-core
  2026-01-20  9:35 ` [ruby-core:124597] " jnchito (Junichi Ito) via ruby-core
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: nobu (Nobuyoshi Nakada) via ruby-core @ 2026-01-20  5:42 UTC (permalink / raw)
  To: ruby-core; +Cc: nobu (Nobuyoshi Nakada)

Issue #21844 has been updated by nobu (Nobuyoshi Nakada).

Backport changed from 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN to 3.2: REQUIRED, 3.3: REQUIRED, 3.4: REQUIRED, 4.0: REQUIRED

Another related issue:


```ruby
Data.define(:a, :b).new(a: 0, "a" => 1)
```

This creates an instance of `Data` with `b` not initialized, `#<data a=1, b=nil>`.

----------------------------------------
Bug #21844: Inconsistent ArgumentError message for Data::define.new
https://bugs.ruby-lang.org/issues/21844#change-116177

* Author: jnchito (Junichi Ito)
* Status: Open
* ruby -v: ruby 4.0.1 (2026-01-13 revision e04267a14b) +PRISM [arm64-darwin25]
* Backport: 3.2: REQUIRED, 3.3: REQUIRED, 3.4: REQUIRED, 4.0: REQUIRED
----------------------------------------
The code below shows `Data::define.new` treats symbol and string keys equivalently:

``` ruby
C = Data.define(:a, :b)

C.new(a: 1, b: 1)
#=> #<data C a=1, b=1>

C.new('a' => 1, 'b' => 1)
#=> #<data C a=1, b=1>
```

But it acts differently when detecting missing keywords:

```ruby
C.new(a: 1)
#=> 'Data#initialize': missing keyword: :b (ArgumentError)
C.new('a' => 1)
#=> 'Data#initialize': missing keywords: :a, :b (ArgumentError)
```

I feel it should work like this:

```ruby
C.new('a' => 1)
#=> 'Data#initialize': missing keyword: :b (ArgumentError)
```

I created a PR to fix it:

https://github.com/ruby/ruby/pull/15910



-- 
https://bugs.ruby-lang.org/
______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [ruby-core:124597] [Ruby Bug#21844] Inconsistent ArgumentError message for Data::define.new
  2026-01-20  4:59 [ruby-core:124594] [Ruby Bug#21844] Inconsistent ArgumentError message for Data::define.new jnchito (Junichi Ito) via ruby-core
  2026-01-20  5:42 ` [ruby-core:124595] " nobu (Nobuyoshi Nakada) via ruby-core
@ 2026-01-20  9:35 ` jnchito (Junichi Ito) via ruby-core
  2026-01-20 12:45 ` [ruby-core:124600] " jnchito (Junichi Ito) via ruby-core
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jnchito (Junichi Ito) via ruby-core @ 2026-01-20  9:35 UTC (permalink / raw)
  To: ruby-core; +Cc: jnchito (Junichi Ito)

Issue #21844 has been updated by jnchito (Junichi Ito).


I fixed that error as well in my PR:

https://github.com/ruby/ruby/pull/15910/

----------------------------------------
Bug #21844: Inconsistent ArgumentError message for Data::define.new
https://bugs.ruby-lang.org/issues/21844#change-116178

* Author: jnchito (Junichi Ito)
* Status: Open
* ruby -v: ruby 4.0.1 (2026-01-13 revision e04267a14b) +PRISM [arm64-darwin25]
* Backport: 3.2: REQUIRED, 3.3: REQUIRED, 3.4: REQUIRED, 4.0: REQUIRED
----------------------------------------
The code below shows `Data::define.new` treats symbol and string keys equivalently:

``` ruby
C = Data.define(:a, :b)

C.new(a: 1, b: 1)
#=> #<data C a=1, b=1>

C.new('a' => 1, 'b' => 1)
#=> #<data C a=1, b=1>
```

But it acts differently when detecting missing keywords:

```ruby
C.new(a: 1)
#=> 'Data#initialize': missing keyword: :b (ArgumentError)
C.new('a' => 1)
#=> 'Data#initialize': missing keywords: :a, :b (ArgumentError)
```

I feel it should work like this:

```ruby
C.new('a' => 1)
#=> 'Data#initialize': missing keyword: :b (ArgumentError)
```

I created a PR to fix it:

https://github.com/ruby/ruby/pull/15910



-- 
https://bugs.ruby-lang.org/
______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [ruby-core:124600] [Ruby Bug#21844] Inconsistent ArgumentError message for Data::define.new
  2026-01-20  4:59 [ruby-core:124594] [Ruby Bug#21844] Inconsistent ArgumentError message for Data::define.new jnchito (Junichi Ito) via ruby-core
  2026-01-20  5:42 ` [ruby-core:124595] " nobu (Nobuyoshi Nakada) via ruby-core
  2026-01-20  9:35 ` [ruby-core:124597] " jnchito (Junichi Ito) via ruby-core
@ 2026-01-20 12:45 ` jnchito (Junichi Ito) via ruby-core
  2026-01-20 23:12 ` [ruby-core:124602] " jnchito (Junichi Ito) via ruby-core
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jnchito (Junichi Ito) via ruby-core @ 2026-01-20 12:45 UTC (permalink / raw)
  To: ruby-core; +Cc: jnchito (Junichi Ito)

Issue #21844 has been updated by jnchito (Junichi Ito).


Is this behavior in Ruby 4.0.1 expected? 

```ruby
Data.define(:a, :b).new(1 => 1, a: 2)
#=> #<data a=2, b=1>

Data.define(:a, :b).new(1 => 1, b: 2)
#=> #<data a=nil, b=2>
```

I expected ArgumentError to be raised because `1` is an unknown keyword.

For example, the following behavior is natural for me:

```ruby
def x(a:,b:);end

x(1=>1,a:2)
#=> missing keyword: :b (ArgumentError)

x(1=>1,b:2)
#=> missing keyword: :a (ArgumentError)

x(1=>1,2=>2)
#=> missing keywords: :a, :b (ArgumentError)
```


----------------------------------------
Bug #21844: Inconsistent ArgumentError message for Data::define.new
https://bugs.ruby-lang.org/issues/21844#change-116182

* Author: jnchito (Junichi Ito)
* Status: Open
* ruby -v: ruby 4.0.1 (2026-01-13 revision e04267a14b) +PRISM [arm64-darwin25]
* Backport: 3.2: REQUIRED, 3.3: REQUIRED, 3.4: REQUIRED, 4.0: REQUIRED
----------------------------------------
The code below shows `Data::define.new` treats symbol and string keys equivalently:

``` ruby
C = Data.define(:a, :b)

C.new(a: 1, b: 1)
#=> #<data C a=1, b=1>

C.new('a' => 1, 'b' => 1)
#=> #<data C a=1, b=1>
```

But it acts differently when detecting missing keywords:

```ruby
C.new(a: 1)
#=> 'Data#initialize': missing keyword: :b (ArgumentError)
C.new('a' => 1)
#=> 'Data#initialize': missing keywords: :a, :b (ArgumentError)
```

I feel it should work like this:

```ruby
C.new('a' => 1)
#=> 'Data#initialize': missing keyword: :b (ArgumentError)
```

I created a PR to fix it:

https://github.com/ruby/ruby/pull/15910



-- 
https://bugs.ruby-lang.org/
______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [ruby-core:124602] [Ruby Bug#21844] Inconsistent ArgumentError message for Data::define.new
  2026-01-20  4:59 [ruby-core:124594] [Ruby Bug#21844] Inconsistent ArgumentError message for Data::define.new jnchito (Junichi Ito) via ruby-core
                   ` (2 preceding siblings ...)
  2026-01-20 12:45 ` [ruby-core:124600] " jnchito (Junichi Ito) via ruby-core
@ 2026-01-20 23:12 ` jnchito (Junichi Ito) via ruby-core
  2026-01-21  0:47 ` [ruby-core:124603] " jnchito (Junichi Ito) via ruby-core
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jnchito (Junichi Ito) via ruby-core @ 2026-01-20 23:12 UTC (permalink / raw)
  To: ruby-core; +Cc: jnchito (Junichi Ito)

Issue #21844 has been updated by jnchito (Junichi Ito).


I couldn't find the spec, but I found keywords can be index like Array:

```ruby
Data.define(:a, :b).new(0 => 1, 1 => 2)
#=> #<data a=1, b=2>

Data.define(:a, :b).new(-2 => 1, -1 => 2)
#=> #<data a=1, b=2>
```

So the code below seems to be OK:

```ruby
Data.define(:a, :b).new(1 => 1, a: 2)
#=> #<data a=2, b=1>
```

But the following code should raise ArgumentError(missing keyword: :a), right?

```ruby
Data.define(:a, :b).new(1 => 1, b: 2)
#=> #<data a=nil, b=2>
```


----------------------------------------
Bug #21844: Inconsistent ArgumentError message for Data::define.new
https://bugs.ruby-lang.org/issues/21844#change-116187

* Author: jnchito (Junichi Ito)
* Status: Open
* ruby -v: ruby 4.0.1 (2026-01-13 revision e04267a14b) +PRISM [arm64-darwin25]
* Backport: 3.2: REQUIRED, 3.3: REQUIRED, 3.4: REQUIRED, 4.0: REQUIRED
----------------------------------------
The code below shows `Data::define.new` treats symbol and string keys equivalently:

``` ruby
C = Data.define(:a, :b)

C.new(a: 1, b: 1)
#=> #<data C a=1, b=1>

C.new('a' => 1, 'b' => 1)
#=> #<data C a=1, b=1>
```

But it acts differently when detecting missing keywords:

```ruby
C.new(a: 1)
#=> 'Data#initialize': missing keyword: :b (ArgumentError)
C.new('a' => 1)
#=> 'Data#initialize': missing keywords: :a, :b (ArgumentError)
```

I feel it should work like this:

```ruby
C.new('a' => 1)
#=> 'Data#initialize': missing keyword: :b (ArgumentError)
```

I created a PR to fix it:

https://github.com/ruby/ruby/pull/15910



-- 
https://bugs.ruby-lang.org/
______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [ruby-core:124603] [Ruby Bug#21844] Inconsistent ArgumentError message for Data::define.new
  2026-01-20  4:59 [ruby-core:124594] [Ruby Bug#21844] Inconsistent ArgumentError message for Data::define.new jnchito (Junichi Ito) via ruby-core
                   ` (3 preceding siblings ...)
  2026-01-20 23:12 ` [ruby-core:124602] " jnchito (Junichi Ito) via ruby-core
@ 2026-01-21  0:47 ` jnchito (Junichi Ito) via ruby-core
  2026-01-22 10:51 ` [ruby-core:124608] " Eregon (Benoit Daloze) via ruby-core
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jnchito (Junichi Ito) via ruby-core @ 2026-01-21  0:47 UTC (permalink / raw)
  To: ruby-core; +Cc: jnchito (Junichi Ito)

Issue #21844 has been updated by jnchito (Junichi Ito).


With this PR, Data#initialize now considers index keys when detecting missing keywords:

https://github.com/ruby/ruby/pull/15910

----------------------------------------
Bug #21844: Inconsistent ArgumentError message for Data::define.new
https://bugs.ruby-lang.org/issues/21844#change-116189

* Author: jnchito (Junichi Ito)
* Status: Open
* ruby -v: ruby 4.0.1 (2026-01-13 revision e04267a14b) +PRISM [arm64-darwin25]
* Backport: 3.2: REQUIRED, 3.3: REQUIRED, 3.4: REQUIRED, 4.0: REQUIRED
----------------------------------------
The code below shows `Data::define.new` treats symbol and string keys equivalently:

``` ruby
C = Data.define(:a, :b)

C.new(a: 1, b: 1)
#=> #<data C a=1, b=1>

C.new('a' => 1, 'b' => 1)
#=> #<data C a=1, b=1>
```

But it acts differently when detecting missing keywords:

```ruby
C.new(a: 1)
#=> 'Data#initialize': missing keyword: :b (ArgumentError)
C.new('a' => 1)
#=> 'Data#initialize': missing keywords: :a, :b (ArgumentError)
```

I feel it should work like this:

```ruby
C.new('a' => 1)
#=> 'Data#initialize': missing keyword: :b (ArgumentError)
```

I created a PR to fix it:

https://github.com/ruby/ruby/pull/15910



-- 
https://bugs.ruby-lang.org/
______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [ruby-core:124608] [Ruby Bug#21844] Inconsistent ArgumentError message for Data::define.new
  2026-01-20  4:59 [ruby-core:124594] [Ruby Bug#21844] Inconsistent ArgumentError message for Data::define.new jnchito (Junichi Ito) via ruby-core
                   ` (4 preceding siblings ...)
  2026-01-21  0:47 ` [ruby-core:124603] " jnchito (Junichi Ito) via ruby-core
@ 2026-01-22 10:51 ` Eregon (Benoit Daloze) via ruby-core
  2026-01-22 13:01 ` [ruby-core:124609] " nobu (Nobuyoshi Nakada) via ruby-core
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Eregon (Benoit Daloze) via ruby-core @ 2026-01-22 10:51 UTC (permalink / raw)
  To: ruby-core; +Cc: Eregon (Benoit Daloze)

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


I think we should be strict with arguments for `Data.new`:
Only keyword arguments with symbol keys, or an Array with the correct number of elements should be accepted, everything else should be an ArgumentError.

`Data.define(:a, :b).new(1 => 1, a: 2)` should be an error, that seems a bug in CRuby (and already an error in TruffleRuby).

----------------------------------------
Bug #21844: Inconsistent ArgumentError message for Data::define.new
https://bugs.ruby-lang.org/issues/21844#change-116195

* Author: jnchito (Junichi Ito)
* Status: Open
* ruby -v: ruby 4.0.1 (2026-01-13 revision e04267a14b) +PRISM [arm64-darwin25]
* Backport: 3.2: REQUIRED, 3.3: REQUIRED, 3.4: REQUIRED, 4.0: REQUIRED
----------------------------------------
The code below shows `Data::define.new` treats symbol and string keys equivalently:

``` ruby
C = Data.define(:a, :b)

C.new(a: 1, b: 1)
#=> #<data C a=1, b=1>

C.new('a' => 1, 'b' => 1)
#=> #<data C a=1, b=1>
```

But it acts differently when detecting missing keywords:

```ruby
C.new(a: 1)
#=> 'Data#initialize': missing keyword: :b (ArgumentError)
C.new('a' => 1)
#=> 'Data#initialize': missing keywords: :a, :b (ArgumentError)
```

I feel it should work like this:

```ruby
C.new('a' => 1)
#=> 'Data#initialize': missing keyword: :b (ArgumentError)
```

I created a PR to fix it:

https://github.com/ruby/ruby/pull/15910



-- 
https://bugs.ruby-lang.org/
______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [ruby-core:124609] [Ruby Bug#21844] Inconsistent ArgumentError message for Data::define.new
  2026-01-20  4:59 [ruby-core:124594] [Ruby Bug#21844] Inconsistent ArgumentError message for Data::define.new jnchito (Junichi Ito) via ruby-core
                   ` (5 preceding siblings ...)
  2026-01-22 10:51 ` [ruby-core:124608] " Eregon (Benoit Daloze) via ruby-core
@ 2026-01-22 13:01 ` nobu (Nobuyoshi Nakada) via ruby-core
  2026-01-22 20:22 ` [ruby-core:124612] " Eregon (Benoit Daloze) via ruby-core
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: nobu (Nobuyoshi Nakada) via ruby-core @ 2026-01-22 13:01 UTC (permalink / raw)
  To: ruby-core; +Cc: nobu (Nobuyoshi Nakada)

Issue #21844 has been updated by nobu (Nobuyoshi Nakada).


@eregon If so, should `deconstruct_keys` also be an error?

```ruby
klass = Data.define(:x, :y)
d = klass.new(1, 2)

d.deconstruct_keys([0, 1]) #=> ?
```

----------------------------------------
Bug #21844: Inconsistent ArgumentError message for Data::define.new
https://bugs.ruby-lang.org/issues/21844#change-116196

* Author: jnchito (Junichi Ito)
* Status: Open
* ruby -v: ruby 4.0.1 (2026-01-13 revision e04267a14b) +PRISM [arm64-darwin25]
* Backport: 3.2: REQUIRED, 3.3: REQUIRED, 3.4: REQUIRED, 4.0: REQUIRED
----------------------------------------
The code below shows `Data::define.new` treats symbol and string keys equivalently:

``` ruby
C = Data.define(:a, :b)

C.new(a: 1, b: 1)
#=> #<data C a=1, b=1>

C.new('a' => 1, 'b' => 1)
#=> #<data C a=1, b=1>
```

But it acts differently when detecting missing keywords:

```ruby
C.new(a: 1)
#=> 'Data#initialize': missing keyword: :b (ArgumentError)
C.new('a' => 1)
#=> 'Data#initialize': missing keywords: :a, :b (ArgumentError)
```

I feel it should work like this:

```ruby
C.new('a' => 1)
#=> 'Data#initialize': missing keyword: :b (ArgumentError)
```

I created a PR to fix it:

https://github.com/ruby/ruby/pull/15910



-- 
https://bugs.ruby-lang.org/
______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [ruby-core:124612] [Ruby Bug#21844] Inconsistent ArgumentError message for Data::define.new
  2026-01-20  4:59 [ruby-core:124594] [Ruby Bug#21844] Inconsistent ArgumentError message for Data::define.new jnchito (Junichi Ito) via ruby-core
                   ` (6 preceding siblings ...)
  2026-01-22 13:01 ` [ruby-core:124609] " nobu (Nobuyoshi Nakada) via ruby-core
@ 2026-01-22 20:22 ` Eregon (Benoit Daloze) via ruby-core
  2026-01-23  9:31 ` [ruby-core:124614] " nobu (Nobuyoshi Nakada) via ruby-core
  2026-02-12  7:13 ` [ruby-core:124778] " matz (Yukihiro Matsumoto) via ruby-core
  9 siblings, 0 replies; 11+ messages in thread
From: Eregon (Benoit Daloze) via ruby-core @ 2026-01-22 20:22 UTC (permalink / raw)
  To: ruby-core; +Cc: Eregon (Benoit Daloze)

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


Yes, I think so, I don't anyone is using something as obscure as `case data in MyData{0 => a, 1 => b}` when they can just `case data in MyData(a:, b:)` or `case data in MyData[a, b]`.

----------------------------------------
Bug #21844: Inconsistent ArgumentError message for Data::define.new
https://bugs.ruby-lang.org/issues/21844#change-116199

* Author: jnchito (Junichi Ito)
* Status: Open
* ruby -v: ruby 4.0.1 (2026-01-13 revision e04267a14b) +PRISM [arm64-darwin25]
* Backport: 3.2: REQUIRED, 3.3: REQUIRED, 3.4: REQUIRED, 4.0: REQUIRED
----------------------------------------
The code below shows `Data::define.new` treats symbol and string keys equivalently:

``` ruby
C = Data.define(:a, :b)

C.new(a: 1, b: 1)
#=> #<data C a=1, b=1>

C.new('a' => 1, 'b' => 1)
#=> #<data C a=1, b=1>
```

But it acts differently when detecting missing keywords:

```ruby
C.new(a: 1)
#=> 'Data#initialize': missing keyword: :b (ArgumentError)
C.new('a' => 1)
#=> 'Data#initialize': missing keywords: :a, :b (ArgumentError)
```

I feel it should work like this:

```ruby
C.new('a' => 1)
#=> 'Data#initialize': missing keyword: :b (ArgumentError)
```

I created a PR to fix it:

https://github.com/ruby/ruby/pull/15910



-- 
https://bugs.ruby-lang.org/
______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [ruby-core:124614] [Ruby Bug#21844] Inconsistent ArgumentError message for Data::define.new
  2026-01-20  4:59 [ruby-core:124594] [Ruby Bug#21844] Inconsistent ArgumentError message for Data::define.new jnchito (Junichi Ito) via ruby-core
                   ` (7 preceding siblings ...)
  2026-01-22 20:22 ` [ruby-core:124612] " Eregon (Benoit Daloze) via ruby-core
@ 2026-01-23  9:31 ` nobu (Nobuyoshi Nakada) via ruby-core
  2026-02-12  7:13 ` [ruby-core:124778] " matz (Yukihiro Matsumoto) via ruby-core
  9 siblings, 0 replies; 11+ messages in thread
From: nobu (Nobuyoshi Nakada) via ruby-core @ 2026-01-23  9:31 UTC (permalink / raw)
  To: ruby-core; +Cc: nobu (Nobuyoshi Nakada)

Issue #21844 has been updated by nobu (Nobuyoshi Nakada).


https://github.com/nobu/ruby/tree/data-missing-keys-symbol-string

----------------------------------------
Bug #21844: Inconsistent ArgumentError message for Data::define.new
https://bugs.ruby-lang.org/issues/21844#change-116201

* Author: jnchito (Junichi Ito)
* Status: Open
* ruby -v: ruby 4.0.1 (2026-01-13 revision e04267a14b) +PRISM [arm64-darwin25]
* Backport: 3.2: REQUIRED, 3.3: REQUIRED, 3.4: REQUIRED, 4.0: REQUIRED
----------------------------------------
The code below shows `Data::define.new` treats symbol and string keys equivalently:

``` ruby
C = Data.define(:a, :b)

C.new(a: 1, b: 1)
#=> #<data C a=1, b=1>

C.new('a' => 1, 'b' => 1)
#=> #<data C a=1, b=1>
```

But it acts differently when detecting missing keywords:

```ruby
C.new(a: 1)
#=> 'Data#initialize': missing keyword: :b (ArgumentError)
C.new('a' => 1)
#=> 'Data#initialize': missing keywords: :a, :b (ArgumentError)
```

I feel it should work like this:

```ruby
C.new('a' => 1)
#=> 'Data#initialize': missing keyword: :b (ArgumentError)
```

I created a PR to fix it:

https://github.com/ruby/ruby/pull/15910



-- 
https://bugs.ruby-lang.org/
______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [ruby-core:124778] [Ruby Bug#21844] Inconsistent ArgumentError message for Data::define.new
  2026-01-20  4:59 [ruby-core:124594] [Ruby Bug#21844] Inconsistent ArgumentError message for Data::define.new jnchito (Junichi Ito) via ruby-core
                   ` (8 preceding siblings ...)
  2026-01-23  9:31 ` [ruby-core:124614] " nobu (Nobuyoshi Nakada) via ruby-core
@ 2026-02-12  7:13 ` matz (Yukihiro Matsumoto) via ruby-core
  9 siblings, 0 replies; 11+ messages in thread
From: matz (Yukihiro Matsumoto) via ruby-core @ 2026-02-12  7:13 UTC (permalink / raw)
  To: ruby-core; +Cc: matz (Yukihiro Matsumoto)

Issue #21844 has been updated by matz (Yukihiro Matsumoto).


OK, these are bugs (string keys, integer keys). We should fix.

Matz.


----------------------------------------
Bug #21844: Inconsistent ArgumentError message for Data::define.new
https://bugs.ruby-lang.org/issues/21844#change-116389

* Author: jnchito (Junichi Ito)
* Status: Open
* ruby -v: ruby 4.0.1 (2026-01-13 revision e04267a14b) +PRISM [arm64-darwin25]
* Backport: 3.2: REQUIRED, 3.3: REQUIRED, 3.4: REQUIRED, 4.0: REQUIRED
----------------------------------------
The code below shows `Data::define.new` treats symbol and string keys equivalently:

``` ruby
C = Data.define(:a, :b)

C.new(a: 1, b: 1)
#=> #<data C a=1, b=1>

C.new('a' => 1, 'b' => 1)
#=> #<data C a=1, b=1>
```

But it acts differently when detecting missing keywords:

```ruby
C.new(a: 1)
#=> 'Data#initialize': missing keyword: :b (ArgumentError)
C.new('a' => 1)
#=> 'Data#initialize': missing keywords: :a, :b (ArgumentError)
```

I feel it should work like this:

```ruby
C.new('a' => 1)
#=> 'Data#initialize': missing keyword: :b (ArgumentError)
```

I created a PR to fix it:

https://github.com/ruby/ruby/pull/15910



-- 
https://bugs.ruby-lang.org/
______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2026-02-12  7:14 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-20  4:59 [ruby-core:124594] [Ruby Bug#21844] Inconsistent ArgumentError message for Data::define.new jnchito (Junichi Ito) via ruby-core
2026-01-20  5:42 ` [ruby-core:124595] " nobu (Nobuyoshi Nakada) via ruby-core
2026-01-20  9:35 ` [ruby-core:124597] " jnchito (Junichi Ito) via ruby-core
2026-01-20 12:45 ` [ruby-core:124600] " jnchito (Junichi Ito) via ruby-core
2026-01-20 23:12 ` [ruby-core:124602] " jnchito (Junichi Ito) via ruby-core
2026-01-21  0:47 ` [ruby-core:124603] " jnchito (Junichi Ito) via ruby-core
2026-01-22 10:51 ` [ruby-core:124608] " Eregon (Benoit Daloze) via ruby-core
2026-01-22 13:01 ` [ruby-core:124609] " nobu (Nobuyoshi Nakada) via ruby-core
2026-01-22 20:22 ` [ruby-core:124612] " Eregon (Benoit Daloze) via ruby-core
2026-01-23  9:31 ` [ruby-core:124614] " nobu (Nobuyoshi Nakada) via ruby-core
2026-02-12  7:13 ` [ruby-core:124778] " matz (Yukihiro Matsumoto) via ruby-core

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).