https://redmine.ruby-lang.org/
https://redmine.ruby-lang.org/favicon.ico?1711330511
2009-12-14T17:06:50Z
Ruby Issue Tracking System
Ruby master - Bug #2476: instance_eval ArgumentError
https://redmine.ruby-lang.org/issues/2476?journal_id=7308
2009-12-14T17:06:50Z
shugo (Shugo Maeda)
<ul></ul><p>=begin<br>
Hi,</p>
<p>2009/12/14 Lourens Naudé <a href="mailto:redmine@ruby-lang.org" class="email">redmine@ruby-lang.org</a>:</p>
<blockquote>
<p>I believe I've found an edge case referencing the recent (Dec 4) changes of instance_eval etc. compatibility with current MRI 1.8 behavior.</p>
<p>Ruby backtrace and context :<br>
<a href="https://gist.github.com/1be3d65c1ff8c23ce964" class="external">https://gist.github.com/1be3d65c1ff8c23ce964</a> ( from sinatra trunk )</p>
<p>C function call :<br>
<a href="http://github.com/methodmissing/ruby/blob/trunk/vm_insnhelper.c#L716" class="external">http://github.com/methodmissing/ruby/blob/trunk/vm_insnhelper.c#L716</a></p>
</blockquote>
<p>I don't know sinatra well, but it passes a Proc object created by<br>
lambda which doesn't take any arguments to instance_eval, doesn't it?<br>
If so, please use Proc.new or proc instead of lambda.</p>
<p>instance_eval yields the receiver in both 1.8 and 1.9.<br>
Unfortunately, a Proc object created by lambda raises ArgumentError<br>
when extra arguments are yielded in 1.9.</p>
<p>defiant:~$ ruby-1_8 -ve 'lambda {}.call("foo")'<br>
ruby 1.8.8dev (2009-12-05 revision 26022) [i686-linux]<br>
defiant:~$ ruby-trunk -ve 'lambda {}.call("foo")'<br>
ruby 1.9.2dev (2009-12-09 trunk 26052) [i686-linux]<br>
-e:1:in <code>call': wrong number of arguments (1 for 0) (ArgumentError) from -e:1:in </code>'</p>
<p>You should use Proc.new or proc instead of lambda if you don't want<br>
checks for the number of arguments.</p>
<p>--<br>
Shugo Maeda</p>
<p>=end</p>
Ruby master - Bug #2476: instance_eval ArgumentError
https://redmine.ruby-lang.org/issues/2476?journal_id=8184
2010-02-06T23:16:17Z
shugo (Shugo Maeda)
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Third Party's Issue</i></li></ul><p>=begin<br>
If you still think that this issue is a bug of Ruby, please reopen this ticket.<br>
=end</p>