summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-16 13:06:10 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-16 13:06:10 +0000
commite0a5ccfec19b157f21a1780cc51e652353f9d0fd (patch)
tree7bdfb8c1bd2e80a53c30a5cd132985349ec643d5
parentc17ee1100763373f069a06adcdb85283e3f16626 (diff)
merge revision(s) r47645: [Backport #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 #10263] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47980 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog8
-rw-r--r--test/ruby/test_super.rb15
-rw-r--r--version.h2
-rw-r--r--vm_eval.c3
4 files changed, 26 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index d73611b9be..d075478438 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Thu Oct 16 22:06:03 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]
+
Thu Oct 16 00:30:30 2014 Tanaka Akira <akr@fsij.org>
* lib/find.rb (Find.find): Call to_path for arguments to obtain
diff --git a/test/ruby/test_super.rb b/test/ruby/test_super.rb
index e42782191d..6278e4b88a 100644
--- a/test/ruby/test_super.rb
+++ b/test/ruby/test_super.rb
@@ -494,4 +494,19 @@ class TestSuper < Test::Unit::TestCase
end
assert_equal(%w[B A], result, bug9721)
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
diff --git a/version.h b/version.h
index 8c09c61a65..07096cb19d 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.1.4"
#define RUBY_RELEASE_DATE "2014-10-16"
-#define RUBY_PATCHLEVEL 257
+#define RUBY_PATCHLEVEL 258
#define RUBY_RELEASE_YEAR 2014
#define RUBY_RELEASE_MONTH 10
diff --git a/vm_eval.c b/vm_eval.c
index cb0e637942..dc0b05375b 100644
--- a/vm_eval.c
+++ b/vm_eval.c
@@ -1211,7 +1211,7 @@ eval_string_with_cref(VALUE self, VALUE src, VALUE scope, NODE *const cref_arg,
absolute_path = file;
}
- if (scope != Qnil) {
+ if (!NIL_P(scope)) {
bind = Check_TypedStruct(scope, &ruby_binding_data_type);
{
envval = bind->env;
@@ -1261,6 +1261,7 @@ eval_string_with_cref(VALUE self, VALUE src, VALUE scope, NODE *const cref_arg,
COPY_CREF(cref, orig_cref);
}
vm_set_eval_stack(th, iseqval, cref, base_block);
+ th->cfp->klass = CLASS_OF(base_block->self);
RB_GC_GUARD(crefval);
if (0) { /* for debug */