Skip to content

Commit

Permalink
No longer ignore fourth argument to foreach/readlines
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Mar 15, 2024
1 parent 7ee4b54 commit 341c3a4
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions core/src/main/java/org/jruby/RubyIO.java
Original file line number Diff line number Diff line change
Expand Up @@ -3840,9 +3840,6 @@ private static IRubyObject foreachInternal(ThreadContext context, IRubyObject re
case 3:
Getline.getlineCall(context, GETLINE_YIELD, io, io.getReadEncoding(context), args[1], args[2], block);
break;
case 4:
Getline.getlineCall(context, GETLINE_YIELD, io, io.getReadEncoding(context), args[1], args[2], args[3], block);
break;
}
} finally {
io.close();
Expand Down Expand Up @@ -4347,7 +4344,7 @@ static IRubyObject seekBeforeAccess(ThreadContext context, RubyIO io, IRubyObjec
}

// rb_io_s_readlines
@JRubyMethod(name = "readlines", required = 1, optional = 3, checkArity = false, meta = true)
@JRubyMethod(name = "readlines", required = 1, optional = 2, checkArity = false, meta = true)
public static IRubyObject readlines(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block unusedBlock) {
IRubyObject opt = ArgsUtil.getOptionsArg(context.runtime, args);
final RubyIO io = openKeyArgs(context, recv, args, opt);
Expand All @@ -4362,11 +4359,8 @@ public static IRubyObject readlines(ThreadContext context, IRubyObject recv, IRu
case 3:
if (opt != context.nil) return io.readlines(context, args[1], opt);
return io.readlines(context, args[1], args[2]);
case 4:
if (opt != context.nil) return io.readlines(context, args[1], args[2], opt);
return io.readlines(context, args[1], args[2], args[3]);
default:
Arity.raiseArgumentError(context, args.length, 1, 4);
Arity.raiseArgumentError(context, args.length, 1, 3);
throw new AssertionError("BUG");
}
} finally { io.close(); }
Expand Down

0 comments on commit 341c3a4

Please sign in to comment.