mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
vm_eval.c: fix super from eval with scope
* vm_eval.c (eval_string_with_cref): fix super from eval with scope. set klass in the current control frame to the class of the receiver in the context to be evaluated, this class/module must match the actual receiver to call super. [ruby-core:65122] [Bug #10263] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47645 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0df55df496
commit
fee7d48517
3 changed files with 25 additions and 1 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
Sat Sep 20 07:55:57 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* vm_eval.c (eval_string_with_cref): fix super from eval with
|
||||||
|
scope. set klass in the current control frame to the class of
|
||||||
|
the receiver in the context to be evaluated, this class/module
|
||||||
|
must match the actual receiver to call super.
|
||||||
|
[ruby-core:65122] [Bug #10263]
|
||||||
|
|
||||||
Fri Sep 19 20:06:00 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Fri Sep 19 20:06:00 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* symbol.c (rb_str_dynamic_intern): check if the stem ID of
|
* symbol.c (rb_str_dynamic_intern): check if the stem ID of
|
||||||
|
|
|
@ -493,4 +493,19 @@ class TestSuper < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
assert_equal(%w[B A], result, bug9721)
|
assert_equal(%w[B A], result, bug9721)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_from_eval
|
||||||
|
bug10263 = '[ruby-core:65122] [Bug #10263a]'
|
||||||
|
a = Class.new do
|
||||||
|
def foo
|
||||||
|
"A"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
b = Class.new(a) do
|
||||||
|
def foo
|
||||||
|
binding.eval("super")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
assert_equal("A", b.new.foo, bug10263)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1215,7 +1215,7 @@ eval_string_with_cref(VALUE self, VALUE src, VALUE scope, NODE *const cref_arg,
|
||||||
absolute_path = file;
|
absolute_path = file;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scope != Qnil) {
|
if (!NIL_P(scope)) {
|
||||||
bind = Check_TypedStruct(scope, &ruby_binding_data_type);
|
bind = Check_TypedStruct(scope, &ruby_binding_data_type);
|
||||||
{
|
{
|
||||||
envval = bind->env;
|
envval = bind->env;
|
||||||
|
@ -1265,6 +1265,7 @@ eval_string_with_cref(VALUE self, VALUE src, VALUE scope, NODE *const cref_arg,
|
||||||
COPY_CREF(cref, orig_cref);
|
COPY_CREF(cref, orig_cref);
|
||||||
}
|
}
|
||||||
vm_set_eval_stack(th, iseqval, cref, base_block);
|
vm_set_eval_stack(th, iseqval, cref, base_block);
|
||||||
|
th->cfp->klass = CLASS_OF(base_block->self);
|
||||||
RB_GC_GUARD(crefval);
|
RB_GC_GUARD(crefval);
|
||||||
|
|
||||||
if (0) { /* for debug */
|
if (0) { /* for debug */
|
||||||
|
|
Loading…
Add table
Reference in a new issue