[ruby-core:124361] [Ruby Bug#21805] Wrong "key not found" in NoMatchingPatternKeyError when destructuring Data
Issue #21805 has been reported by esad (Esad Hajdarevic). ---------------------------------------- Bug #21805: Wrong "key not found" in NoMatchingPatternKeyError when destructuring Data https://bugs.ruby-lang.org/issues/21805 * Author: esad (Esad Hajdarevic) * Status: Open * ruby -v: ruby 4.0.0 (2025-12-25 revision 553f1675f3) +PRISM [arm64-darwin24] * Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- Consider ``` Foo = Data.define(:x) Foo.new(1) => {x:, z:} ``` It raises `#<data Foo x=1>: key not found: :x (NoMatchingPatternKeyError)` Clearly the message is misleading, as it is key :z that is missing. -- https://bugs.ruby-lang.org/
Issue #21805 has been updated by afurm (Andrii Furmanets). Thanks. The https://github.com/ruby/ruby/pull/15748 will fix the issue. ---------------------------------------- Bug #21805: Wrong "key not found" in NoMatchingPatternKeyError when destructuring Data https://bugs.ruby-lang.org/issues/21805#change-115885 * Author: esad (Esad Hajdarevic) * Status: Open * ruby -v: ruby 4.0.0 (2025-12-25 revision 553f1675f3) +PRISM [arm64-darwin24] * Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- Consider ``` Foo = Data.define(:x) Foo.new(1) => {x:, z:} ``` It raises `#<data Foo x=1>: key not found: :x (NoMatchingPatternKeyError)` Clearly the message is misleading, as it is key :z that is missing. -- https://bugs.ruby-lang.org/
participants (2)
-
afurm (Andrii Furmanets) -
esad (Esad Hajdarevic)