diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-10-17 04:13:38 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-10-17 04:13:38 +0000 |
commit | 6d886eb2557fe846957da483ab08f7c964e95679 (patch) | |
tree | 9ac5968fc1c472288c59a77c27390509333819de | |
parent | 7e344b0b7b877fcf203ab29f56e417993fb4cb11 (diff) |
merge revision(s) 47645: [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_0_0@47987 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | test/ruby/test_super.rb | 15 | ||||
-rw-r--r-- | version.h | 6 | ||||
-rw-r--r-- | vm_eval.c | 3 |
4 files changed, 28 insertions, 4 deletions
@@ -1,3 +1,11 @@ +Fri Oct 17 13:10:08 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 16:33:51 2014 NAKAMURA Usaku <usa@ruby-lang.org> * regcomp.c, regexec.c: Optimization should be disabled not only for diff --git a/test/ruby/test_super.rb b/test/ruby/test_super.rb index 44fdf850fc..cb76236f9c 100644 --- a/test/ruby/test_super.rb +++ b/test/ruby/test_super.rb @@ -495,4 +495,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 @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.0.0" -#define RUBY_RELEASE_DATE "2014-10-16" -#define RUBY_PATCHLEVEL 587 +#define RUBY_RELEASE_DATE "2014-10-17" +#define RUBY_PATCHLEVEL 588 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 10 -#define RUBY_RELEASE_DAY 16 +#define RUBY_RELEASE_DAY 17 #include "ruby/version.h" @@ -1187,7 +1187,7 @@ eval_string_with_cref(VALUE self, VALUE src, VALUE scope, NODE *cref, volatile V absolute_path = file; } - if (scope != Qnil) { + if (!NIL_P(scope)) { if (rb_obj_is_kind_of(scope, rb_cBinding)) { GetBindingPtr(scope, bind); envval = bind->env; @@ -1231,6 +1231,7 @@ eval_string_with_cref(VALUE self, VALUE src, VALUE scope, NODE *cref, volatile V th->parse_in_eval--; vm_set_eval_stack(th, iseqval, cref, base_block); + th->cfp->klass = CLASS_OF(base_block->self); if (0) { /* for debug */ VALUE disasm = rb_iseq_disasm(iseqval); |