From: mame@... Date: 2018-12-13T08:21:16+00:00 Subject: [ruby-core:90499] [Ruby trunk Bug#15409] OpenStruct error when attribute is called 'method' Issue #15409 has been updated by mame (Yusuke Endoh). > `OpenStruct` is kind of an anti-pattern. Completely agreed. I'd like to prohibit the library itself, honestly. > I note that Struct allows overriding builtin methods: Interesting. I believe no one passes untrusted keys to Struct. But I heard that OpenStruct is used for JSON. > o = OpenStruct.new > o.then # => nil in Ruby 2.5, Enumerator in Ruby 2.6 Ah... It's just a design flaw. ---------------------------------------- Bug #15409: OpenStruct error when attribute is called 'method' https://bugs.ruby-lang.org/issues/15409#change-75656 * Author: elioncho (El��as Orozco) * Status: Assigned * Priority: Normal * Assignee: marcandre (Marc-Andre Lafortune) * Target version: * ruby -v: ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin16] * Backport: 2.4: UNKNOWN, 2.5: UNKNOWN ---------------------------------------- The following error is shown when you try to access an OpenStruct with a property called method: `method': wrong number of arguments (given 0, expected 1) (ArgumentError) To replicate: ~~~ ruby require 'ostruct' o = OpenStruct.new({ method: 'get' }) o.method ~~~ The expected behavior should be to return 'get' -- https://bugs.ruby-lang.org/ Unsubscribe: