ruby-changes:33281
From: sorah <ko1@a...>
Date: Tue, 18 Mar 2014 23:06:40 +0900 (JST)
Subject: [ruby-changes:33281] sorah:r45360 (trunk): * vm_eval.c (eval_string_with_cref): Use file path even if scope is
sorah 2014-03-18 23:06:34 +0900 (Tue, 18 Mar 2014) New Revision: 45360 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=45360 Log: * vm_eval.c (eval_string_with_cref): Use file path even if scope is given. Related to [ruby-core:56099] [Bug #8662] and r42103. Modified files: trunk/ChangeLog trunk/test/ruby/test_method.rb trunk/vm_eval.c Index: ChangeLog =================================================================== --- ChangeLog (revision 45359) +++ ChangeLog (revision 45360) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Tue Mar 18 22:03:41 2014 Shota Fukumori <her@s...> + + * vm_eval.c (eval_string_with_cref): Use file path even if scope is + given. Related to [ruby-core:56099] [Bug #8662] and r42103. + Mon Mar 17 13:17:47 2014 Koichi Sasada <ko1@a...> * enumerator.c (enumerator_block_call): use RARRAY_CONST_PTR() Index: vm_eval.c =================================================================== --- vm_eval.c (revision 45359) +++ vm_eval.c (revision 45360) @@ -1215,14 +1215,15 @@ eval_string_with_cref(VALUE self, VALUE https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1215 VALUE absolute_path = Qnil; VALUE fname; + if (file != Qundef) { + absolute_path = file; + } + if (scope != Qnil) { bind = Check_TypedStruct(scope, &ruby_binding_data_type); { envval = bind->env; - if (file != Qundef) { - absolute_path = file; - } - else if (!NIL_P(bind->path)) { + if (absolute_path == Qnil && !NIL_P(bind->path)) { file = bind->path; line = bind->first_lineno; absolute_path = rb_current_realfilepath(); Index: test/ruby/test_method.rb =================================================================== --- test/ruby/test_method.rb (revision 45359) +++ test/ruby/test_method.rb (revision 45360) @@ -660,6 +660,7 @@ class TestMethod < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_method.rb#L660 assert_equal(__dir__, eval("__dir__", binding), bug8436) bug8662 = '[ruby-core:56099] [Bug #8662]' assert_equal("arbitrary", eval("__dir__", binding, "arbitrary/file.rb"), bug8662) + assert_equal("arbitrary", Object.new.instance_eval("__dir__", "arbitrary/file.rb"), bug8662) end def test_alias_owner -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/