Skip to content

Commit dac945b

Browse files
committed
merge revision(s) r47645: [Backport ruby#10263]
* 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 ruby#10263] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47980 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 90c3ddc commit dac945b

File tree

4 files changed

+26
-2
lines changed

4 files changed

+26
-2
lines changed

ChangeLog

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
Thu Oct 16 22:06:03 2014 Nobuyoshi Nakada <[email protected]>
2+
3+
* vm_eval.c (eval_string_with_cref): fix super from eval with
4+
scope. set klass in the current control frame to the class of
5+
the receiver in the context to be evaluated, this class/module
6+
must match the actual receiver to call super.
7+
[ruby-core:65122] [Bug #10263]
8+
19
Thu Oct 16 00:30:30 2014 Tanaka Akira <[email protected]>
210

311
* lib/find.rb (Find.find): Call to_path for arguments to obtain

test/ruby/test_super.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,4 +494,19 @@ def foo(result)
494494
end
495495
assert_equal(%w[B A], result, bug9721)
496496
end
497+
498+
def test_from_eval
499+
bug10263 = '[ruby-core:65122] [Bug #10263a]'
500+
a = Class.new do
501+
def foo
502+
"A"
503+
end
504+
end
505+
b = Class.new(a) do
506+
def foo
507+
binding.eval("super")
508+
end
509+
end
510+
assert_equal("A", b.new.foo, bug10263)
511+
end
497512
end

version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#define RUBY_VERSION "2.1.4"
22
#define RUBY_RELEASE_DATE "2014-10-16"
3-
#define RUBY_PATCHLEVEL 257
3+
#define RUBY_PATCHLEVEL 258
44

55
#define RUBY_RELEASE_YEAR 2014
66
#define RUBY_RELEASE_MONTH 10

vm_eval.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1211,7 +1211,7 @@ eval_string_with_cref(VALUE self, VALUE src, VALUE scope, NODE *const cref_arg,
12111211
absolute_path = file;
12121212
}
12131213

1214-
if (scope != Qnil) {
1214+
if (!NIL_P(scope)) {
12151215
bind = Check_TypedStruct(scope, &ruby_binding_data_type);
12161216
{
12171217
envval = bind->env;
@@ -1261,6 +1261,7 @@ eval_string_with_cref(VALUE self, VALUE src, VALUE scope, NODE *const cref_arg,
12611261
COPY_CREF(cref, orig_cref);
12621262
}
12631263
vm_set_eval_stack(th, iseqval, cref, base_block);
1264+
th->cfp->klass = CLASS_OF(base_block->self);
12641265
RB_GC_GUARD(crefval);
12651266

12661267
if (0) { /* for debug */

0 commit comments

Comments
 (0)