Skip to content

Commit

Permalink
Make write return Int instead of UInt in an obscure code-path. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
LilithHafner authored and pull[bot] committed Jun 5, 2024
1 parent 3899e45 commit 6bb8306
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ unsafe_write(s::IO, p::Ptr, n::Integer) = unsafe_write(s, convert(Ptr{UInt8}, p)
function write(s::IO, x::Ref{T}) where {T}
x isa Ptr && error("write cannot copy from a Ptr")
if isbitstype(T)
unsafe_write(s, x, Core.sizeof(T))
Int(unsafe_write(s, x, Core.sizeof(T)))
else
write(s, x[])
end
Expand Down
4 changes: 4 additions & 0 deletions test/filesystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,7 @@ end
@test_broken isempty(undoc)
@test undoc == [:File, :Filesystem, :cptree, :futime, :rename, :sendfile, :unlink]
end

@testet "write return type" begin
@test Base.return_types(write, (Base.Filesystem.File, UInt8)) == [Int]
end

0 comments on commit 6bb8306

Please sign in to comment.