ruby-changes:59250
From: Nobuyoshi <ko1@a...>
Date: Sun, 15 Dec 2019 00:57:04 +0900 (JST)
Subject: [ruby-changes:59250] 38b9d213f1 (master): Revert "[DOC] Fixed the class name in FrozenError#receiver"
https://git.ruby-lang.org/ruby.git/commit/?id=38b9d213f1 From 38b9d213f1fc474549d7ca6858ed4f1d1436d1ee Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Sun, 15 Dec 2019 00:18:09 +0900 Subject: Revert "[DOC] Fixed the class name in FrozenError#receiver" This reverts commit 5f56a5fc9be9ea7b088795c2d3871c2352a020c2. `FrozenError.new(mesg, nil).receiver` should not raise an ArgumentError. diff --git a/error.c b/error.c index a3821e6..7ef252f 100644 --- a/error.c +++ b/error.c @@ -1409,17 +1409,6 @@ exit_success_p(VALUE exc) https://github.com/ruby/ruby/blob/trunk/error.c#L1409 return Qfalse; } -static VALUE -err_attr_receiver(VALUE self) -{ - VALUE recv; - - recv = rb_ivar_lookup(self, id_receiver, Qundef); - if (recv == Qundef) - rb_raise(rb_eArgError, "no receiver is available"); - return recv; -} - /* * call-seq: * FrozenError.new(msg=nil, receiver=nil) -> frozen_error @@ -1446,15 +1435,6 @@ frozen_err_initialize(int argc, VALUE *argv, VALUE self) https://github.com/ruby/ruby/blob/trunk/error.c#L1435 return self; } -/* - * call-seq: - * frozen_error.receiver -> object - * - * Return the receiver associated with this FrozenError exception. - */ - -#define frozen_err_receiver err_attr_receiver - void rb_name_error(ID id, const char *fmt, ...) { @@ -1822,7 +1802,15 @@ rb_invalid_str(const char *str, const char *type) https://github.com/ruby/ruby/blob/trunk/error.c#L1802 * Return the receiver associated with this KeyError exception. */ -#define key_err_receiver err_attr_receiver +static VALUE +key_err_receiver(VALUE self) +{ + VALUE recv; + + recv = rb_ivar_lookup(self, id_receiver, Qundef); + if (recv != Qundef) return recv; + rb_raise(rb_eArgError, "no receiver is available"); +} /* * call-seq: @@ -2541,7 +2529,7 @@ Init_Exception(void) https://github.com/ruby/ruby/blob/trunk/error.c#L2529 rb_eRuntimeError = rb_define_class("RuntimeError", rb_eStandardError); rb_eFrozenError = rb_define_class("FrozenError", rb_eRuntimeError); rb_define_method(rb_eFrozenError, "initialize", frozen_err_initialize, -1); - rb_define_method(rb_eFrozenError, "receiver", frozen_err_receiver, 0); + rb_define_method(rb_eFrozenError, "receiver", name_err_receiver, 0); rb_eSecurityError = rb_define_class("SecurityError", rb_eException); rb_eNoMemError = rb_define_class("NoMemoryError", rb_eException); rb_eEncodingError = rb_define_class("EncodingError", rb_eStandardError); -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/