https://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112009-10-08T19:35:19ZRuby Issue Tracking SystemBackport187 - Backport #2161: Kernel.eval ignores binding in 1.9https://redmine.ruby-lang.org/issues/2161?journal_id=61402009-10-08T19:35:19Zwanabe (_ wanabe)s.wanabe@gmail.com
<ul></ul><p>=begin<br>
It seems that Kernel#eval works fine.</p>
<p>$ ./ruby -ve 'class Foo;def foo;binding;end;end;eval "p self", Foo.new.foo'<br>
ruby 1.9.2dev (2009-10-02 trunk 25185) [i386-mingw32]<br>
#<a href="Foo:0xb23f80" class="external">Foo:0xb23f80</a></p>
<p>I guess <code>obj.send(:binding)' is same as </code>binding' in 1.9.<br>
And it is undefined behavior, because Kernel#binding is a private method.<br>
How about Object#instance_eval instead of it?<br>
=end</p> Backport187 - Backport #2161: Kernel.eval ignores binding in 1.9https://redmine.ruby-lang.org/issues/2161?journal_id=63712009-10-21T23:11:41Znaruse (Yui NARUSE)naruse@airemix.jp
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Feedback</i></li></ul><p>=begin</p>
<p>=end</p> Backport187 - Backport #2161: Kernel.eval ignores binding in 1.9https://redmine.ruby-lang.org/issues/2161?journal_id=102442010-04-16T22:40:50Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul></ul><p>=begin<br>
Hi,</p>
<p>Rdoc of Kernel#binding says:</p>
<p>Returns a +Binding+ object, describing the variable and<br>
method bindings at the point of call.</p>
<p>In this case, "the point of call" is top level.<br>
So I think 1.9 is correct.</p>
<p>I don't know it is 1.8's bug or spec change since 1.9.<br>
So I move this ticket to 1.8 subproject.</p>
<p>As wanabe said, you can use instance_eval if you want 1.8's<br>
current behavior:</p>
<p>eval "self", obj.instance_eval { binding }</p>
<p>--<br>
Yusuke Endoh <a href="mailto:mame@tsg.ne.jp" class="email">mame@tsg.ne.jp</a><br>
=end</p> Backport187 - Backport #2161: Kernel.eval ignores binding in 1.9https://redmine.ruby-lang.org/issues/2161?journal_id=794912019-07-15T15:19:41Zjeremyevans0 (Jeremy Evans)merch-redmine@jeremyevans.net
<ul><li><strong>Tracker</strong> changed from <i>Bug</i> to <i>Backport</i></li><li><strong>Project</strong> changed from <i>Ruby 1.8</i> to <i>Backport187</i></li><li><strong>Description</strong> updated (<a title="View differences" href="/journals/79491/diff?detail_id=52901">diff</a>)</li><li><strong>Status</strong> changed from <i>Feedback</i> to <i>Closed</i></li><li><strong>ruby -v</strong> deleted (<del><i>1.9.1p243 (2009-07-16 revision 24175) [i386-darwin9.8.0]</i></del>)</li></ul>