From b271ca8c62f7f8a81c9b1d05dbf710b9ca0828a4 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: svn+ssh://ci.ruby-lang.org/ruby/trunk@25998 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ lib/irb/extend-command.rb | 22 +++++++++++----------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index edebd54e89..3ffb9d5a3e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sat Dec 5 10:18:26 2009 Nobuyoshi Nakada + + * lib/irb/extend-command.rb (def_extend_command): fixed argument + number for negative arity. + Fri Dec 4 16:50:13 2009 Nobuyoshi Nakada * parse.y (k_def): adjust the location of method definition to the diff --git a/lib/irb/extend-command.rb b/lib/irb/extend-command.rb index 7bc033cee1..190c49ae78 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<