ruby-changes:59247
From: Nobuyoshi <ko1@a...>
Date: Sun, 15 Dec 2019 00:15:20 +0900 (JST)
Subject: [ruby-changes:59247] 5f56a5fc9b (master): [DOC] Fixed the class name in FrozenError#receiver
https://git.ruby-lang.org/ruby.git/commit/?id=5f56a5fc9b From 5f56a5fc9be9ea7b088795c2d3871c2352a020c2 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Sat, 14 Dec 2019 23:57:44 +0900 Subject: [DOC] Fixed the class name in FrozenError#receiver diff --git a/error.c b/error.c index 7ef252f..a3821e6 100644 --- a/error.c +++ b/error.c @@ -1409,6 +1409,17 @@ 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 @@ -1435,6 +1446,15 @@ frozen_err_initialize(int argc, VALUE *argv, VALUE self) https://github.com/ruby/ruby/blob/trunk/error.c#L1446 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, ...) { @@ -1802,15 +1822,7 @@ rb_invalid_str(const char *str, const char *type) https://github.com/ruby/ruby/blob/trunk/error.c#L1822 * Return the receiver associated with this KeyError exception. */ -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"); -} +#define key_err_receiver err_attr_receiver /* * call-seq: @@ -2529,7 +2541,7 @@ Init_Exception(void) https://github.com/ruby/ruby/blob/trunk/error.c#L2541 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", name_err_receiver, 0); + rb_define_method(rb_eFrozenError, "receiver", frozen_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/