Project

General

Profile

Actions

Bug #21844

open

Inconsistent ArgumentError message for Data::define.new

Bug #21844: Inconsistent ArgumentError message for Data::define.new

Added by jnchito (Junichi Ito) 1 day ago. Updated about 20 hours ago.

Status:
Open
Assignee:
-
Target version:
-
ruby -v:
ruby 4.0.1 (2026-01-13 revision e04267a14b) +PRISM [arm64-darwin25]
[ruby-core:124594]

Description

The code below shows Data::define.new treats symbol and string keys equivalently:

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:

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:

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

I created a PR to fix it:

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

Actions

Also available in: PDF Atom