summaryrefslogtreecommitdiff
path: root/eval.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-11-20 07:31:55 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-11-20 07:31:55 +0000
commit39563af99459820ada08e30e379c84b4560c3fe9 (patch)
tree5844d64e2d5e0b5a7b9dfc259037778db84b12aa /eval.c
parent8f54a9b4704e5416290a5670519ae7bc869de0e8 (diff)
matz
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1049 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/eval.c b/eval.c
index c0d47bf..03ae377 100644
--- a/eval.c
+++ b/eval.c
@@ -2594,17 +2594,19 @@ rb_eval(self, n)
rb_const_set(ruby_class, node->nd_vid, result);
break;
- case NODE_CVASGN2:
- result = rb_eval(self, node->nd_value);
- rb_cvar_set_singleton(self, node->nd_vid, result);
- break;
-
case NODE_CVDECL:
if (NIL_P(ruby_cbase)) {
rb_raise(rb_eTypeError, "no class/module to define class variable");
}
+ if (!FL_TEST(ruby_cbase, FL_SINGLETON)) {
+ result = rb_eval(self, node->nd_value);
+ rb_cvar_declare(ruby_cbase, node->nd_vid, result);
+ break;
+ }
+ /* fall through */
+ case NODE_CVASGN2:
result = rb_eval(self, node->nd_value);
- rb_cvar_declare(ruby_cbase, node->nd_vid, result);
+ rb_cvar_set_singleton(self, node->nd_vid, result);
break;
case NODE_LVAR: