From: "Eregon (Benoit Daloze) via ruby-core" Date: 2026-05-18T21:13:04+00:00 Subject: [ruby-core:125540] [Ruby Bug#21844] Inconsistent ArgumentError message for Data::define.new Issue #21844 has been updated by Eregon (Benoit Daloze). @nobu Was it intentional to keep accepting `String` and `to_str` kwargs in addition to Symbols? >From what matz said above I would expect only Symbols are accepted, which would be valuable to optimize `Data#initialize` better. ---------------------------------------- Bug #21844: Inconsistent ArgumentError message for Data::define.new https://bugs.ruby-lang.org/issues/21844#change-117366 * Author: jnchito (Junichi Ito) * Status: Closed * ruby -v: ruby 4.0.1 (2026-01-13 revision e04267a14b) +PRISM [arm64-darwin25] * Backport: 3.2: WONTFIX, 3.3: REQUIRED, 3.4: REQUIRED, 4.0: DONE ---------------------------------------- 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) #=> # C.new('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/