From: Shugo Maeda Date: 2009-12-14T17:06:37+09:00 Subject: [ruby-core:27165] Re: [Bug #2476] instance_eval ArgumentError Hi, 2009/12/14 Lourens Naud� : > 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. > > Ruby backtrace and context : > https://gist.github.com/1be3d65c1ff8c23ce964 ( from sinatra trunk ) > > C function call : > http://github.com/methodmissing/ruby/blob/trunk/vm_insnhelper.c#L716 I don't know sinatra well, but it passes a Proc object created by lambda which doesn't take any arguments to instance_eval, doesn't it? If so, please use Proc.new or proc instead of lambda. instance_eval yields the receiver in both 1.8 and 1.9. Unfortunately, a Proc object created by lambda raises ArgumentError when extra arguments are yielded in 1.9. defiant:~$ ruby-1_8 -ve 'lambda {}.call("foo")' ruby 1.8.8dev (2009-12-05 revision 26022) [i686-linux] defiant:~$ ruby-trunk -ve 'lambda {}.call("foo")' ruby 1.9.2dev (2009-12-09 trunk 26052) [i686-linux] -e:1:in `call': wrong number of arguments (1 for 0) (ArgumentError) from -e:1:in `
' You should use Proc.new or proc instead of lambda if you don't want checks for the number of arguments. -- Shugo Maeda