From 46e660b5d1a5db87026a4b2dcf1e596d24c6fea8 Mon Sep 17 00:00:00 2001 From: Kristoffer Carlsson Date: Wed, 8 May 2024 10:00:56 +0200 Subject: [PATCH] fix `code_warntype` on `OpaqueClosure`s (#54378) Fixes https://github.com/JuliaLang/julia/issues/54375 --------- Co-authored-by: Shuhei Kadowaki --- stdlib/InteractiveUtils/src/codeview.jl | 2 +- stdlib/InteractiveUtils/test/runtests.jl | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/stdlib/InteractiveUtils/src/codeview.jl b/stdlib/InteractiveUtils/src/codeview.jl index 4fb7610d4ad0d..015269d4d8dc0 100644 --- a/stdlib/InteractiveUtils/src/codeview.jl +++ b/stdlib/InteractiveUtils/src/codeview.jl @@ -153,7 +153,7 @@ function code_warntype(io::IO, @nospecialize(f), @nospecialize(tt=Base.default_t lineprinter = Base.IRShow.__debuginfo[debuginfo] nargs::Int = 0 if isa(f, Core.OpaqueClosure) - isa(f.source, Method) && (nargs = f.nargs) + isa(f.source, Method) && (nargs = f.source.nargs) print_warntype_codeinfo(io, Base.code_typed_opaque_closure(f, tt)[1]..., nargs; lineprinter) return nothing end diff --git a/stdlib/InteractiveUtils/test/runtests.jl b/stdlib/InteractiveUtils/test/runtests.jl index 22789be2c5495..dbae46e1c902a 100644 --- a/stdlib/InteractiveUtils/test/runtests.jl +++ b/stdlib/InteractiveUtils/test/runtests.jl @@ -138,6 +138,11 @@ tag = "ANY" @test !warntype_hastag(ImportIntrinsics15819.sqrt15819, Tuple{Float64}, tag) @test !warntype_hastag(ImportIntrinsics15819.sqrt15819, Tuple{Float32}, tag) +@testset "code_warntype OpaqueClosure" begin + g = Base.Experimental.@opaque Tuple{Float64} x -> 0.0 + @test warntype_hastag(g, Tuple{Float64}, "::Float64") +end + end # module WarnType # Adds test for PR #17636