From: kimmo.lehto@... Date: 2019-08-08T08:56:42+00:00 Subject: [ruby-core:94195] [Ruby master Bug#16086] OpenStruct method access with a block does not raise Issue #16086 has been reported by kke (Kimmo Lehto). ---------------------------------------- Bug #16086: OpenStruct method access with a block does not raise https://bugs.ruby-lang.org/issues/16086 * Author: kke (Kimmo Lehto) * Status: Open * Priority: Normal * Assignee: * Target version: * ruby -v: * Backport: 2.5: UNKNOWN, 2.6: UNKNOWN ---------------------------------------- This can cause confusion. ```ruby > OpenStruct.new(hello: 'world').each { |k, v| puts k.upcase } # there's no "each" method => nil > OpenStruct.new(hello: 'world').eahc_pair { |k, v| puts k.upcase } # each_pair typo => nil ``` An undefined key with a block should maybe raise `NoMethodError` or `ArgumentError`? A defined key with a block seems to yield the value, I don't see this being documented: ```ruby > OpenStruct.new(hello: 'world').hello { |k| puts k.upcase } HELLO ``` Maybe it should raise `ArgumentError` too? Related: https://bugs.ruby-lang.org/issues/15515 -- https://bugs.ruby-lang.org/ Unsubscribe: