diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | lib/forwardable.rb | 7 | ||||
-rw-r--r-- | test/test_forwardable.rb | 13 | ||||
-rw-r--r-- | version.h | 2 |
4 files changed, 17 insertions, 12 deletions
@@ -1,3 +1,10 @@ +Mon Mar 19 00:04:08 2018 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * lib/forwardable.rb (_delegator_method): leave the backtrace + untouched during accessor. forwardable.rb does not appear in + the backtrace during delegated method because of tail-call + optimization. + Sun Mar 18 23:59:32 2018 Nobuyoshi Nakada <nobu@ruby-lang.org> dup String#partition return value diff --git a/lib/forwardable.rb b/lib/forwardable.rb index e78b9ed1e0..e2b210423f 100644 --- a/lib/forwardable.rb +++ b/lib/forwardable.rb @@ -113,12 +113,9 @@ module Forwardable # Version of +forwardable.rb+ FORWARDABLE_VERSION = "1.1.0" - FILE_REGEXP = %r"#{Regexp.quote(__FILE__)}" - @debug = nil class << self - # If true, <tt>__FILE__</tt> will remain in the backtrace in the event an - # Exception is raised. + # ignored attr_accessor :debug end @@ -203,8 +200,6 @@ module Forwardable def #{ali}(*args, &block) begin #{accessor} - ensure - $@.delete_if {|s| ::Forwardable::FILE_REGEXP =~ s} if $@ and !::Forwardable::debug end.__send__ :#{method}, *args, &block end end diff --git a/test/test_forwardable.rb b/test/test_forwardable.rb index f678ca4fc7..9d159de826 100644 --- a/test/test_forwardable.rb +++ b/test/test_forwardable.rb @@ -225,18 +225,21 @@ class TestForwardable < Test::Unit::TestCase class Foo extend Forwardable + attr_accessor :bar def_delegator :bar, :baz def_delegator :caller, :itself, :c - - class Exception - end end def test_backtrace_adjustment + obj = Foo.new + def (obj.bar = Object.new).baz + foo + end e = assert_raise(NameError) { - Foo.new.baz + obj.baz } - assert_not_match(/\/forwardable\.rb/, e.backtrace[0]) + assert_not_match(/\/forwardable\.rb/, e.backtrace[0], + proc {RubyVM::InstructionSequence.of(obj.method(:baz)).disassemble}) assert_equal(caller(0, 1)[0], Foo.new.c[0]) end @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.3.7" #define RUBY_RELEASE_DATE "2018-03-19" -#define RUBY_PATCHLEVEL 420 +#define RUBY_PATCHLEVEL 421 #define RUBY_RELEASE_YEAR 2018 #define RUBY_RELEASE_MONTH 3 |