ruby-changes:56395
From: Nobuyoshi <ko1@a...>
Date: Tue, 9 Jul 2019 11:01:43 +0900 (JST)
Subject: [ruby-changes:56395] Nobuyoshi Nakada: 4cda2e5013 (master): Moved error messages
https://git.ruby-lang.org/ruby.git/commit/?id=4cda2e5013 From 4cda2e5013b1351b9da087fe534907fcd7e52770 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Tue, 9 Jul 2019 10:58:12 +0900 Subject: Moved error messages diff --git a/object.c b/object.c index 08cb218..3fc1ed9 100644 --- a/object.c +++ b/object.c @@ -2262,9 +2262,14 @@ rb_class_get_superclass(VALUE klass) https://github.com/ruby/ruby/blob/trunk/object.c#L2262 return RCLASS(klass)->super; } +static const char bad_instance_name[] = "`%1$s' is not allowed as an instance variable name"; +static const char bad_class_name[] = "`%1$s' is not allowed as a class variable name"; +static const char bad_const_name[] = "wrong constant name %1$s"; +static const char bad_attr_name[] = "invalid attribute name `%1$s'"; +#define wrong_constant_name bad_const_name + /*! \private */ -#define id_for_var(obj, name, part, type) \ - id_for_setter(obj, name, type, "`%1$s' is not allowed as "#part" "#type" variable name") +#define id_for_var(obj, name, type) id_for_setter(obj, name, type, bad_##type##_name) /*! \private */ #define id_for_setter(obj, name, type, message) \ check_setter_id(obj, &(name), rb_is_##type##_id, rb_is_##type##_name, message, strlen(message)) @@ -2295,13 +2300,10 @@ rb_is_attr_id(ID id) https://github.com/ruby/ruby/blob/trunk/object.c#L2300 return rb_is_local_id(id) || rb_is_const_id(id); } -static const char wrong_constant_name[] = "wrong constant name %1$s"; -static const char invalid_attribute_name[] = "invalid attribute name `%1$s'"; - static ID id_for_attr(VALUE obj, VALUE name) { - ID id = id_for_setter(obj, name, attr, invalid_attribute_name); + ID id = id_for_var(obj, name, attr); if (!id) id = rb_intern_str(name); return id; } @@ -2566,7 +2568,7 @@ rb_mod_const_get(int argc, VALUE *argv, VALUE mod) https://github.com/ruby/ruby/blob/trunk/object.c#L2568 static VALUE rb_mod_const_set(VALUE mod, VALUE name, VALUE value) { - ID id = id_for_setter(mod, name, const, wrong_constant_name); + ID id = id_for_var(mod, name, const); if (!id) id = rb_intern_str(name); rb_const_set(mod, id, value); @@ -2844,7 +2846,7 @@ rb_mod_const_source_location(int argc, VALUE *argv, VALUE mod) https://github.com/ruby/ruby/blob/trunk/object.c#L2846 static VALUE rb_obj_ivar_get(VALUE obj, VALUE iv) { - ID id = id_for_var(obj, iv, an, instance); + ID id = id_for_var(obj, iv, instance); if (!id) { return Qnil; @@ -2878,7 +2880,7 @@ rb_obj_ivar_get(VALUE obj, VALUE iv) https://github.com/ruby/ruby/blob/trunk/object.c#L2880 static VALUE rb_obj_ivar_set(VALUE obj, VALUE iv, VALUE val) { - ID id = id_for_var(obj, iv, an, instance); + ID id = id_for_var(obj, iv, instance); if (!id) id = rb_intern_str(iv); return rb_ivar_set(obj, id, val); } @@ -2906,7 +2908,7 @@ rb_obj_ivar_set(VALUE obj, VALUE iv, VALUE val) https://github.com/ruby/ruby/blob/trunk/object.c#L2908 static VALUE rb_obj_ivar_defined(VALUE obj, VALUE iv) { - ID id = id_for_var(obj, iv, an, instance); + ID id = id_for_var(obj, iv, instance); if (!id) { return Qfalse; @@ -2933,7 +2935,7 @@ rb_obj_ivar_defined(VALUE obj, VALUE iv) https://github.com/ruby/ruby/blob/trunk/object.c#L2935 static VALUE rb_mod_cvar_get(VALUE obj, VALUE iv) { - ID id = id_for_var(obj, iv, a, class); + ID id = id_for_var(obj, iv, class); if (!id) { rb_name_err_raise("uninitialized class variable %1$s in %2$s", @@ -2965,7 +2967,7 @@ rb_mod_cvar_get(VALUE obj, VALUE iv) https://github.com/ruby/ruby/blob/trunk/object.c#L2967 static VALUE rb_mod_cvar_set(VALUE obj, VALUE iv, VALUE val) { - ID id = id_for_var(obj, iv, a, class); + ID id = id_for_var(obj, iv, class); if (!id) id = rb_intern_str(iv); rb_cvar_set(obj, id, val); return val; @@ -2990,7 +2992,7 @@ rb_mod_cvar_set(VALUE obj, VALUE iv, VALUE val) https://github.com/ruby/ruby/blob/trunk/object.c#L2992 static VALUE rb_mod_cvar_defined(VALUE obj, VALUE iv) { - ID id = id_for_var(obj, iv, a, class); + ID id = id_for_var(obj, iv, class); if (!id) { return Qfalse; -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/