From: josh.cheek@... Date: 2016-12-04T17:20:11+00:00 Subject: [ruby-core:78486] [Ruby trunk Bug#13005] Inline rescue is inconsistent when rescuing NoMethodError Issue #13005 has been reported by Josh Cheek. ---------------------------------------- Bug #13005: Inline rescue is inconsistent when rescuing NoMethodError https://bugs.ruby-lang.org/issues/13005 * Author: Josh Cheek * Status: Open * Priority: Normal * Assignee: * ruby -v: ruby 2.4.0dev (2016-11-16 trunk 56815) [x86_64-darwin15] * Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN ---------------------------------------- ```ruby o = "some object" class << o private attr_accessor :a end # GETTER can be rescued in a begin-block or inline begin o.a rescue; $!.class # => NoMethodError end o.a rescue $!.class # => NoMethodError # SETTER can be rescued in a begin-block but NOT inline! begin o.a = 1 rescue; $!.class # => NoMethodError end o.a = 1 rescue $!.class # ~> NoMethodError # ~> private method `a=' called for "some object":String # ~> Did you mean? a # ~> # ~> program.rb:18:in `
' ``` -- https://bugs.ruby-lang.org/ Unsubscribe: