Skip to content

Commit 683c0c0

Browse files
LilithHafnerlazarusA
authored andcommitted
Make write return Int instead of UInt in an obscure code-path. (JuliaLang#54197)
1 parent 2042875 commit 683c0c0

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

base/io.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ unsafe_write(s::IO, p::Ptr, n::Integer) = unsafe_write(s, convert(Ptr{UInt8}, p)
804804
function write(s::IO, x::Ref{T}) where {T}
805805
x isa Ptr && error("write cannot copy from a Ptr")
806806
if isbitstype(T)
807-
unsafe_write(s, x, Core.sizeof(T))
807+
Int(unsafe_write(s, x, Core.sizeof(T)))
808808
else
809809
write(s, x[])
810810
end

test/filesystem.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,7 @@ end
4646
@test_broken isempty(undoc)
4747
@test undoc == [:File, :Filesystem, :cptree, :futime, :rename, :sendfile, :unlink]
4848
end
49+
50+
@testet "write return type" begin
51+
@test Base.return_types(write, (Base.Filesystem.File, UInt8)) == [Int]
52+
end

0 commit comments

Comments
 (0)