diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-04-23 02:35:58 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-04-23 02:35:58 +0000 |
commit | c2a04d87d0f51e871e2fc0254ce6f90136b50169 (patch) | |
tree | 968463bfcd8001f0940b5ee9654a49437a93b4f9 /class.c | |
parent | 3badcfc1cb87a85ff2d45896be053f12a0958356 (diff) | |
download | ruby-c2a04d87d0f51e871e2fc0254ce6f90136b50169.tar.gz |
vm_eval.c: allow symbols to instance_eval/exec
* vm_eval.c (rb_obj_instance_eval, rb_obj_instance_exec): allow
symbols to just instance_eval/exec, execept for definition of
singletons. [ruby-core:68961] [Bug #11086]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50372 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'class.c')
-rw-r--r-- | class.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -1539,7 +1539,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)) { @@ -1549,9 +1550,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; } } |