From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-4.1 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id 0F01620248 for ; Fri, 12 Apr 2019 22:42:19 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id ED049121915; Sat, 13 Apr 2019 07:42:14 +0900 (JST) Received: from o1678916x28.outbound-mail.sendgrid.net (o1678916x28.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id BD6A6121698 for ; Sat, 13 Apr 2019 07:42:11 +0900 (JST) Received: by filter0162p3mdw1.sendgrid.net with SMTP id filter0162p3mdw1-7628-5CB11443-15 2019-04-12 22:42:11.518340506 +0000 UTC m=+186777.705093493 Received: from herokuapp.com (unknown [3.85.79.146]) by ismtpd0004p1iad1.sendgrid.net (SG) with ESMTP id Aofj4ECPRwKMsJMihEEOng for ; Fri, 12 Apr 2019 22:42:11.458 +0000 (UTC) Date: Fri, 12 Apr 2019 22:42:11 +0000 (UTC) From: ruby-core@marc-andre.ca Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 67750 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 15515 X-Redmine-Issue-Author: lugray X-Redmine-Issue-Assignee: marcandre X-Redmine-Sender: marcandre X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: =?us-ascii?Q?jp+swDN4yjawvlS938eDTV7AcuBgTjW2xvQn0nZL4RCcqf07B30OnsAY6J4alY?= =?us-ascii?Q?vV14CF7KwXjYrMRC7qNIPKK+Bi9EWZENHc5a1IC?= =?us-ascii?Q?pQbD2eIzayXjvlkvoi=2FBvZwK3eF=2Ftqlgk75Au3N?= =?us-ascii?Q?aA1XNcJi0sUkTK6AJS3u2QFPLuvXErocaz=2FA75J?= =?us-ascii?Q?T2lfvLvaS=2Fu1uBrHQQO1QmRbXZdLqoy6MIQ=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 92266 Subject: [ruby-core:92266] [Ruby trunk Bug#15515] OpenStruct raising NoMethodError instead of ArgumentError X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #15515 has been updated by marcandre (Marc-Andre Lafortune). Assignee set to marcandre (Marc-Andre Lafortune) Sorry I missed this. I'm positive on this patch and will commit it shortly unless there's any objection. ---------------------------------------- Bug #15515: OpenStruct raising NoMethodError instead of ArgumentError https://bugs.ruby-lang.org/issues/15515#change-77599 * Author: lugray (Lisa Ugray) * Status: Open * Priority: Normal * Assignee: marcandre (Marc-Andre Lafortune) * Target version: * ruby -v: ruby 2.7.0dev (2019-01-07 trunk 66747) [x86_64-darwin18] * Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN ---------------------------------------- When an `OpenStruct` has some attribute `foo`, calling the `foo` method with an argument gives a no method error: ```ruby foo = OpenStruct.new(bar: 'baz') foo.bar(0) # => NoMethodError (undefined method `bar' for #) ``` This is confusing, since `foo.respond_to?(:bar) # => true`. I would expect: ```ruby foo = OpenStruct.new(bar: 'baz') foo.bar(0) # => ArgumentError (wrong number of arguments (given 1, expected 0)) ``` The included fixes this, and adjusts the arity `ArgumentError` for the setter to be in line with the default arity messaging too. ---Files-------------------------------- 0001-ostruct.rb-refine-arity-failure-message.patch (1.26 KB) 0001-ostruct.rb-refine-arity-failure-message.patch (1.96 KB) -- https://bugs.ruby-lang.org/