summaryrefslogtreecommitdiff
path: root/struct.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-28 06:24:12 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-28 06:24:12 +0000
commit72ff61f4a8ae7a8bf05b0bd6f91b3b290645627c (patch)
tree731069832b17cffaafc9fdcdd394f1976c7ec576 /struct.c
parent7a929727f6a4e45a0ebf0542650ff122b16264ad (diff)
downloadruby-72ff61f4a8ae7a8bf05b0bd6f91b3b290645627c.tar.gz
NameError#receiver of uninitialized constant
* error.c (name_err_mesg_to_str): quote the name if unprintable. * object.c (check_setter_id): use rb_check_id to convert names. * variable.c (uninitialized_constant): use NameError::message to keep the receiver of uninitialized constant. [Feature #10881] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52321 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'struct.c')
-rw-r--r--struct.c25
1 files changed, 9 insertions, 16 deletions
diff --git a/struct.c b/struct.c
index 0d979c8aac..817e0a1b9b 100644
--- a/struct.c
+++ b/struct.c
@@ -201,13 +201,6 @@ rb_struct_members_m(VALUE obj)
return rb_struct_s_members_m(rb_obj_class(obj));
}
-NORETURN(static void not_a_member(ID id));
-static void
-not_a_member(ID id)
-{
- rb_name_error(id, "`%"PRIsVALUE"' is not a struct member", QUOTE_ID(id));
-}
-
VALUE
rb_struct_getmember(VALUE obj, ID id)
{
@@ -216,7 +209,7 @@ rb_struct_getmember(VALUE obj, ID id)
if (i != -1) {
return RSTRUCT_GET(obj, i);
}
- not_a_member(id);
+ rb_name_err_raise("`%1$s' is not a struct member", obj, ID2SYM(id));
UNREACHABLE;
}
@@ -272,8 +265,8 @@ new_struct(VALUE name, VALUE super)
ID id;
name = rb_str_to_str(name);
if (!rb_is_const_name(name)) {
- rb_name_error_str(name, "identifier %"PRIsVALUE" needs to be constant",
- QUOTE(name));
+ rb_name_err_raise("identifier %1$s needs to be constant",
+ super, name);
}
id = rb_to_id(name);
if (rb_const_defined_at(super, id)) {
@@ -830,7 +823,7 @@ rb_struct_aref_sym(VALUE s, VALUE name)
if (pos != -1) {
return RSTRUCT_GET(s, pos);
}
- rb_name_error_str(name, "no member '% "PRIsVALUE"' in struct", name);
+ rb_name_err_raise("no member '%1$s' in struct", s, name);
UNREACHABLE;
}
@@ -863,8 +856,8 @@ rb_struct_aref(VALUE s, VALUE idx)
else if (RB_TYPE_P(idx, T_STRING)) {
ID id = rb_check_id(&idx);
if (!id) {
- rb_name_error_str(idx, "no member '%"PRIsVALUE"' in struct",
- QUOTE(idx));
+ rb_name_err_raise("no member '%1$s' in struct",
+ s, idx);
}
return rb_struct_aref_sym(s, ID2SYM(id));
}
@@ -890,7 +883,7 @@ rb_struct_aset_sym(VALUE s, VALUE name, VALUE val)
return val;
}
- rb_name_error_str(name, "no member '% "PRIsVALUE"' in struct", name);
+ rb_name_err_raise("no member '%1$s' in struct", s, name);
UNREACHABLE;
}
@@ -925,8 +918,8 @@ rb_struct_aset(VALUE s, VALUE idx, VALUE val)
if (RB_TYPE_P(idx, T_STRING)) {
ID id = rb_check_id(&idx);
if (!id) {
- rb_name_error_str(idx, "no member '%"PRIsVALUE"' in struct",
- QUOTE(idx));
+ rb_name_err_raise("no member '%1$s' in struct",
+ s, idx);
}
return rb_struct_aset_sym(s, ID2SYM(id), val);
}