Skip to content

Commit

Permalink
fix #26419, be able to infer read(filename, String)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Jul 10, 2018
1 parent 90bdc77 commit b86b44e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions base/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,8 @@ Read the entire contents of a file as a string.
"""
read(filename::AbstractString, args...) = open(io->read(io, args...), filename)

read(filename::AbstractString, ::Type{T}) where {T} = open(io->read(io, T), filename)

"""
read!(stream::IO, array::Union{Array, BitArray})
read!(filename::AbstractString, array::Union{Array, BitArray})
Expand Down
3 changes: 3 additions & 0 deletions test/read.jl
Original file line number Diff line number Diff line change
Expand Up @@ -568,3 +568,6 @@ let p = Pipe()
@test length(s) == 660_000 + typemax(UInt16)
@test s[(end - typemax(UInt16)):end] == UInt16.(0:typemax(UInt16))
end

# issue #26419
@test Base.return_types(read, (String, Type{String})) == Any[String]

0 comments on commit b86b44e

Please sign in to comment.