Skip to content

Commit

Permalink
[fix #74] should not define the method into special constant objects …
Browse files Browse the repository at this point in the history
…and symbols via instance_{eval, exec}
  • Loading branch information
Watson1978 committed May 16, 2012
1 parent c1bb396 commit 092ad9e
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions vm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1607,12 +1607,12 @@ rb_vm_alias2(VALUE outer, VALUE name, VALUE def, unsigned char dynamic_class)
{
if (dynamic_class) {
Class k = GET_VM()->get_current_class();
if (k != NULL) {
outer = (VALUE)k;
}
else if (RCLASS_SUPER(outer) == 0) {
if (NIL_P(outer)) {
rb_raise(rb_eTypeError, "no class to make alias");
}
else if (k != NULL) {
outer = (VALUE)k;
}
}

// Given arguments should always be symbols (compiled as such).
Expand Down Expand Up @@ -2132,20 +2132,20 @@ prepare_method(Class klass, bool dynamic_class, SEL sel, void *data,
else {
k = o->klass;
}
if (k != NULL) {
if (NIL_P(k)) {
rb_raise(rb_eTypeError, "no class/module to add method");
}
else if (klass != NULL) {
const bool meta = class_isMetaClass(klass);
klass = k;
if (meta && !class_isMetaClass(klass)) {
klass = *(Class *)klass;
}
}
else if (RCLASS_SUPER(klass) == 0) {
rb_raise(rb_eTypeError, "no class/module to add method");
}
}
else {
rb_vm_outer_t *o = GET_VM()->get_outer_stack();
if (o != NULL && o->klass == NULL) {
if ((o != NULL && o->klass == NULL) || NIL_P(o)) {
rb_raise(rb_eTypeError, "no class/module to add method");
}
}
Expand Down Expand Up @@ -4229,6 +4229,9 @@ rb_vm_run_under(VALUE klass, VALUE self, const char *fname, NODE *node,
klass = (VALUE)o->klass;
}
}
if (NIL_P(klass)) {
klass = 0;
}
if (self != 0) {
vm->set_current_top_object(self);
}
Expand Down

0 comments on commit 092ad9e

Please sign in to comment.