Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some error messages to make MRI test pass #8220

Merged
merged 4 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 4 additions & 5 deletions core/src/main/java/org/jruby/RubyHash.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
21 changes: 9 additions & 12 deletions core/src/main/java/org/jruby/RubySignalException.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/ruby/jruby/kernel/jruby/process_util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions test/mri/excludes/TestArity.rb

This file was deleted.