Project

General

Profile

Actions

Bug #18767

closed

IO.foreach hangs up when passes limit=0

Added by andrykonchin (Andrew Konchin) over 2 years ago. Updated about 2 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:108499]

Description

IO.foreach behaves in an unexpected way in a corner case when passes 0 as a limit parameter. It never stops and hangs up.

IO.foreach('file.txt', 0) { |s| p s }
""
""
""
""
""
""
""
""
""
""

Expected behavior - to raise ArgumentError "invalid limit: 0" like it does the IO.readlines method.

I observe this behavior on 2.6, 2.7, and 3.0. Didn't check on 3.1 and master though.


Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #4024: IO#readlines(0) never returnClosed11/04/2010Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0