From 0a663381cd2fc3dcad65811be1c066119e01456a Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 5 Dec 2009 01:18:28 +0000 Subject: * lib/irb/extend-command.rb (def_extend_command): fixed argument number for negative arity. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@25998 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/irb/extend-command.rb | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'lib') diff --git a/lib/irb/extend-command.rb b/lib/irb/extend-command.rb index 7bc033cee..190c49ae7 100644 --- a/lib/irb/extend-command.rb +++ b/lib/irb/extend-command.rb @@ -122,28 +122,28 @@ module IRB end if load_file - eval %[ + line = __LINE__; eval %[ def #{cmd_name}(*opts, &b) require "#{load_file}" arity = ExtendCommand::#{cmd_class}.instance_method(:execute).arity - args = (1..arity.abs).map {|i| "arg" + i.to_s } + args = (1..(arity < 0 ? ~arity : arity)).map {|i| "arg" + i.to_s } args << "*opts" if arity < 0 args << "&block" args = args.join(", ") - eval %[ + line = __LINE__; eval %[ def #{cmd_name}(\#{args}) ExtendCommand::#{cmd_class}.execute(irb_context, \#{args}) end - ] + ], nil, __FILE__, line send :#{cmd_name}, *opts, &b end - ] + ], nil, __FILE__, line else - eval %[ + line = __LINE__; eval %[ def #{cmd_name}(*opts, &b) ExtendCommand::#{cmd_class}.execute(irb_context, *opts, &b) end - ] + ], nil, __FILE__, line end for ali, flag in aliases @@ -160,7 +160,7 @@ module IRB (override == OVERRIDE_PRIVATE_ONLY) && !respond_to?(to) or (override == NO_OVERRIDE) && !respond_to?(to, true) target = self - (class<