ruby-changes:35899
From: nagachika <ko1@a...>
Date: Thu, 16 Oct 2014 22:06:22 +0900 (JST)
Subject: [ruby-changes:35899] nagachika:r47980 (ruby_2_1): merge revision(s) r47645: [Backport #10263]
nagachika 2014-10-16 22:06:10 +0900 (Thu, 16 Oct 2014) New Revision: 47980 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=47980 Log: 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] Modified directories: branches/ruby_2_1/ Modified files: branches/ruby_2_1/ChangeLog branches/ruby_2_1/test/ruby/test_super.rb branches/ruby_2_1/version.h branches/ruby_2_1/vm_eval.c Index: ruby_2_1/ChangeLog =================================================================== --- ruby_2_1/ChangeLog (revision 47979) +++ ruby_2_1/ChangeLog (revision 47980) @@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/ChangeLog#L1 +Thu Oct 16 22:06:03 2014 Nobuyoshi Nakada <nobu@r...> + + * 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@f...> * lib/find.rb (Find.find): Call to_path for arguments to obtain Index: ruby_2_1/vm_eval.c =================================================================== --- ruby_2_1/vm_eval.c (revision 47979) +++ ruby_2_1/vm_eval.c (revision 47980) @@ -1211,7 +1211,7 @@ eval_string_with_cref(VALUE self, VALUE https://github.com/ruby/ruby/blob/trunk/ruby_2_1/vm_eval.c#L1211 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 https://github.com/ruby/ruby/blob/trunk/ruby_2_1/vm_eval.c#L1261 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 */ Index: ruby_2_1/version.h =================================================================== --- ruby_2_1/version.h (revision 47979) +++ ruby_2_1/version.h (revision 47980) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/version.h#L1 #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 Index: ruby_2_1/test/ruby/test_super.rb =================================================================== --- ruby_2_1/test/ruby/test_super.rb (revision 47979) +++ ruby_2_1/test/ruby/test_super.rb (revision 47980) @@ -494,4 +494,19 @@ class TestSuper < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/ruby/test_super.rb#L494 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 Property changes on: ruby_2_1 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r47645 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/