Project

General

Profile

Bug #2476

instance_eval ArgumentError

Added by methodmissing (Lourens Naudé) over 9 years ago. Updated over 8 years ago.

Status:
Third Party's Issue
Priority:
Normal
Target version:
-
ruby -v:
ruby 1.9.2dev (2009-12-10 trunk 26065)
Backport:
[ruby-core:27155]

Description

=begin
Hi,

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

Version ruby 1.9.2dev (2009-12-03 trunk 25980 doesn't reproduce.

  • Lourens =end

History

#1

Updated by shugo (Shugo Maeda) over 9 years ago

=begin
Hi,

2009/12/14 Lourens Naudé redmine@ruby-lang.org:

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

=end

#2

Updated by shugo (Shugo Maeda) over 9 years ago

  • Status changed from Open to Third Party's Issue

=begin
If you still think that this issue is a bug of Ruby, please reopen this ticket.
=end

Also available in: Atom PDF