From 6b319b687e3928f529d39d40d580ec2d48e925f7 Mon Sep 17 00:00:00 2001 From: Gabriel Baraldi Date: Tue, 25 Jul 2023 13:55:26 -0300 Subject: [PATCH 1/2] Make reintepret specialize fully --- base/essentials.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/base/essentials.jl b/base/essentials.jl index 68dd0c06d646f..ad6e02cab145c 100644 --- a/base/essentials.jl +++ b/base/essentials.jl @@ -571,8 +571,8 @@ julia> reinterpret(Tuple{UInt16, UInt8}, (0x01, 0x0203)) otherwise be prevented by the type's constructors and methods. Unexpected behavior may result without additional validation. """ -function reinterpret(Out::Type, x::In) where {In} - if isprimitivetype(Out) && isprimitivetype(In) +function reinterpret(::Type{Out}, x) where {Out} + if isprimitivetype(Out) && isprimitivetype(typeof(x)) return bitcast(Out, x) end # only available when Base is fully loaded. From b0e0d606cd3eccbbafd47c6bc7b436f55ad17509 Mon Sep 17 00:00:00 2001 From: Gabriel Baraldi Date: Tue, 25 Jul 2023 16:52:43 -0300 Subject: [PATCH 2/2] Add test so we don't regress on this --- test/compiler/inline.jl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/compiler/inline.jl b/test/compiler/inline.jl index be821a88f00cc..3bc7ab5ccbc82 100644 --- a/test/compiler/inline.jl +++ b/test/compiler/inline.jl @@ -2061,3 +2061,7 @@ let src = code_typed1((Union{DataType,UnionAll},); interp=NoCompileSigInvokes()) (x.args[1]::MethodInstance).specTypes == Tuple{typeof(no_compile_sig_invokes),UnionAll} end == 1 end + +# https://github.com/JuliaLang/julia/issues/50612 +f50612(x) = UInt32(x) +@test all(!isinvoke(:UInt32),get_code(f50612,Tuple{Char}))