Skip to content

Commit a21a62e

Browse files
committed
Type-stabilize eachline
1 parent cfcaecd commit a21a62e

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

base/io.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -558,11 +558,11 @@ removed. When called with a file name, the file is opened once at the beginning
558558
iteration and closed at the end. If iteration is interrupted, the file will be
559559
closed when the `EachLine` object is garbage collected.
560560
"""
561-
eachline(stream::IO=STDIN; chomp::Bool=true) = EachLine(stream, chomp=chomp)
561+
eachline(stream::IO=STDIN; chomp::Bool=true) = EachLine(stream, chomp=chomp)::EachLine
562562

563563
function eachline(filename::AbstractString; chomp::Bool=true)
564564
s = open(filename)
565-
EachLine(s, ondone=()->close(s), chomp=chomp)
565+
EachLine(s, ondone=()->close(s), chomp=chomp)::EachLine
566566
end
567567

568568
start(itr::EachLine) = nothing

base/process.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ function eachline(cmd::AbstractCmd, stdin; chomp::Bool=true)
562562
out = stdout.out
563563
# implicitly close after reading lines, since we opened
564564
return EachLine(out, chomp=chomp,
565-
ondone=()->(close(out); success(processes) || pipeline_error(processes)))
565+
ondone=()->(close(out); success(processes) || pipeline_error(processes)))::EachLine
566566
end
567567
eachline(cmd::AbstractCmd; chomp::Bool=true) = eachline(cmd, DevNull, chomp=chomp)
568568

test/read.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ for (name, f) in l
252252
@test collect(eachline(io(), chomp=false)) == collect(eachline(IOBuffer(text), chomp=false))
253253
@test collect(eachline(io(), chomp=false)) == collect(eachline(filename, chomp=false))
254254
@test collect(eachline(io())) == collect(eachline(IOBuffer(text)))
255-
@test collect(eachline(io())) == collect(eachline(filename))
255+
@test collect(@inferred(eachline(io()))) == collect(@inferred(eachline(filename))) #20351
256256

257257
cleanup()
258258

0 commit comments

Comments
 (0)