From 341c3a4d606a191c56058eb6c2a387dc0e544a9a Mon Sep 17 00:00:00 2001 From: Charles Oliver Nutter Date: Fri, 15 Mar 2024 15:59:30 -0500 Subject: [PATCH] No longer ignore fourth argument to foreach/readlines https://bugs.ruby-lang.org/issues/18771 --- core/src/main/java/org/jruby/RubyIO.java | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/core/src/main/java/org/jruby/RubyIO.java b/core/src/main/java/org/jruby/RubyIO.java index af917201038..6f44424df8f 100644 --- a/core/src/main/java/org/jruby/RubyIO.java +++ b/core/src/main/java/org/jruby/RubyIO.java @@ -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(); @@ -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); @@ -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(); }