aboutsummaryrefslogtreecommitdiffstats
path: root/proc.c
diff options
context:
space:
mode:
author卜部昌平 <shyouhei@ruby-lang.org>2020-06-16 12:00:49 +0900
committer卜部昌平 <shyouhei@ruby-lang.org>2020-06-29 11:05:41 +0900
commit8b9b51bb3ba246590e528702285f5f5e92271b50 (patch)
treecbf312686c510cb95e78fb4a027e2d30c93af88b /proc.c
parent2390a8bd2ef197faf94b5251ee9a0ea582ff6fb4 (diff)
downloadruby-8b9b51bb3ba246590e528702285f5f5e92271b50.tar.gz
rb_method_name_error: do not goto into a branch
I'm not necessarily against every goto in general, but jumping into a branch is definitely a bad idea. Better refactor.
Diffstat (limited to 'proc.c')
-rw-r--r--proc.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/proc.c b/proc.c
index 371aa83dc0..3ebd8d4535 100644
--- a/proc.c
+++ b/proc.c
@@ -1865,7 +1865,7 @@ rb_method_name_error(VALUE klass, VALUE str)
{
#define MSG(s) rb_fstring_lit("undefined method `%1$s' for"s" `%2$s'")
VALUE c = klass;
- VALUE s;
+ VALUE s = Qundef;
if (FL_TEST(c, FL_SINGLETON)) {
VALUE obj = rb_ivar_get(klass, attached);
@@ -1878,13 +1878,11 @@ rb_method_name_error(VALUE klass, VALUE str)
default:
break;
}
- goto normal_class;
}
else if (RB_TYPE_P(c, T_MODULE)) {
s = MSG(" module");
}
- else {
- normal_class:
+ if (s == Qundef) {
s = MSG(" class");
}
rb_name_err_raise_str(s, c, str);