Skip to content

Commit

Permalink
fixed case below.
Browse files Browse the repository at this point in the history
$b = proc do p X end
module A
  X = :ko
  begin
    module_eval &$b
  rescue NameError
    p :ok
  end
end
  • Loading branch information
Kouji Takao committed May 3, 2011
1 parent 4dd62cd commit 98484c6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions kernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,16 @@ vm_get_const(VALUE outer, uint64_t outer_mask, void *cache_p, ID path,
const bool lexical_lookup = (flags & CONST_LOOKUP_LEXICAL);
const bool dynamic_class = (flags & CONST_LOOKUP_DYNAMIC_CLASS);

if (dynamic_class) {
Class k = rb_vm_get_current_class();
if (lexical_lookup && k != NULL) {
outer = (VALUE)k;
if (dynamic_class && lexical_lookup) {
rb_vm_outer_t *o = outer_stack;
while (o != NULL && o->pushed_by_eval) {
o = o->outer;
}
if (o == NULL) {
outer = rb_cNSObject;
}
else {
outer = (VALUE)o->klass;
}
}

Expand Down
2 changes: 1 addition & 1 deletion test_vm/eval.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ module A
p :ok
end
end
}, :known_bug => true
}

assert ':ok', %{
module A
Expand Down

0 comments on commit 98484c6

Please sign in to comment.