From 6bb8306bcd3155c76b1e89d0526c179b39a15a54 Mon Sep 17 00:00:00 2001 From: Lilith Orion Hafner Date: Thu, 9 May 2024 14:32:36 -0500 Subject: [PATCH] Make `write` return `Int` instead of `UInt` in an obscure code-path. (#54197) --- base/io.jl | 2 +- test/filesystem.jl | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/base/io.jl b/base/io.jl index fb883234be4df6..9f5bbf7416a9a8 100644 --- a/base/io.jl +++ b/base/io.jl @@ -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 diff --git a/test/filesystem.jl b/test/filesystem.jl index 566ca08ec910e4..625bfc38e5e2f7 100644 --- a/test/filesystem.jl +++ b/test/filesystem.jl @@ -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