summaryrefslogtreecommitdiff
path: root/class.c
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-05-20 15:51:27 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-05-20 15:51:27 +0000
commit534c2b03b30d60d2490a5550c7c43b2272b108d1 (patch)
tree6bb7dc01a2aa2b29dcf5981981df8ee0d4e2d0fe /class.c
parent20ef4699e510f89ad4e9ccbeafa2d3d725ed2d3c (diff)
merge revision(s) 50372,50373: [Backport #11086]
* vm_eval.c (rb_obj_instance_eval, rb_obj_instance_exec): allow symbols to just instance_eval/exec, except for definition of singletons. [ruby-core:68961] [Bug #11086] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@50561 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'class.c')
-rw-r--r--class.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/class.c b/class.c
index 65d0d30abd..f142f4472a 100644
--- a/class.c
+++ b/class.c
@@ -1531,7 +1531,8 @@ singleton_class_of(VALUE obj)
{
VALUE klass;
- if (FIXNUM_P(obj) || FLONUM_P(obj) || SYMBOL_P(obj)) {
+ if (FIXNUM_P(obj) || FLONUM_P(obj) || STATIC_SYM_P(obj)) {
+ no_singleton:
rb_raise(rb_eTypeError, "can't define singleton");
}
if (SPECIAL_CONST_P(obj)) {
@@ -1541,9 +1542,9 @@ singleton_class_of(VALUE obj)
return klass;
}
else {
- enum ruby_value_type type = BUILTIN_TYPE(obj);
- if (type == T_FLOAT || type == T_BIGNUM) {
- rb_raise(rb_eTypeError, "can't define singleton");
+ switch (BUILTIN_TYPE(obj)) {
+ case T_FLOAT: case T_BIGNUM: case T_SYMBOL:
+ goto no_singleton;
}
}