diff --git a/core/src/main/java/org/jruby/RubyHash.java b/core/src/main/java/org/jruby/RubyHash.java index c5b39bce15b..205ceca7001 100644 --- a/core/src/main/java/org/jruby/RubyHash.java +++ b/core/src/main/java/org/jruby/RubyHash.java @@ -814,11 +814,10 @@ public IRubyObject initialize(ThreadContext context, final Block block) { public IRubyObject initialize(ThreadContext context, IRubyObject _default, final Block block) { modify(); - if (block.isGiven()) { - throw context.runtime.newArgumentError("wrong number of arguments"); - } else { - ifNone = _default; - } + if (block.isGiven()) throw context.runtime.newArgumentError(1, 0); + + ifNone = _default; + return this; } diff --git a/core/src/main/java/org/jruby/RubySignalException.java b/core/src/main/java/org/jruby/RubySignalException.java index 04c9f95ebc8..fa9ed8f6e7a 100644 --- a/core/src/main/java/org/jruby/RubySignalException.java +++ b/core/src/main/java/org/jruby/RubySignalException.java @@ -62,26 +62,23 @@ static RubyClass define(Ruby runtime, RubyClass exceptionClass) { return signalExceptionClass; } - @JRubyMethod(optional = 2, checkArity = false, visibility = PRIVATE) + @JRubyMethod(required = 1, optional = 2, checkArity = false, visibility = PRIVATE) public IRubyObject initialize(ThreadContext context, IRubyObject[] args, Block block) { - int argc = Arity.checkArgumentCount(context, args, 0, 2); + int argc = Arity.checkArgumentCount(context, args, 1, 2); final Ruby runtime = context.runtime; int argnum = 1; - IRubyObject sig = context.nil; - long _signo; - if (argc > 0) { - sig = TypeConverter.checkToInteger(runtime, args[0], "to_int"); + IRubyObject sig = TypeConverter.checkToInteger(runtime, args[0], "to_int"); - if (sig.isNil()) { - sig = args[0]; - } else { - argnum = 2; - } + if (sig.isNil()) { + sig = args[0]; + Arity.checkArgumentCount(runtime, args, 1, argnum); + } else { + argnum = 2; } - Arity.checkArgumentCount(runtime, args, 1, argnum); + long _signo; if (argnum == 2) { _signo = sig.convertToInteger().getLongValue(); diff --git a/core/src/main/ruby/jruby/kernel/jruby/process_util.rb b/core/src/main/ruby/jruby/kernel/jruby/process_util.rb index 7786153dcd9..b009973d390 100644 --- a/core/src/main/ruby/jruby/kernel/jruby/process_util.rb +++ b/core/src/main/ruby/jruby/kernel/jruby/process_util.rb @@ -4,7 +4,7 @@ def self.exec_args(args) env, prog, opts = nil if args.size < 1 - raise ArgumentError, 'wrong number of arguments' + raise ArgumentError, 'wrong number of arguments (given 0, expected 1+)' end # peel off options diff --git a/test/mri/excludes/TestArity.rb b/test/mri/excludes/TestArity.rb deleted file mode 100644 index 760fd49eb42..00000000000 --- a/test/mri/excludes/TestArity.rb +++ /dev/null @@ -1,3 +0,0 @@ -exclude :test_message_change_issue_6085, "needs investigation" -exclude :test_method_err_mess, "needs investigation" -exclude :test_proc_err_mess, "needs investigation" \ No newline at end of file