Skip to content

IRShow: pass idx::Int to line_info_postprinter #42137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions base/compiler/ssair/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ function should_print_ssa_type(@nospecialize node)
!isa(node, QuoteNode)
end

function default_expr_type_printer(io::IO, @nospecialize(typ), used::Bool)
function default_expr_type_printer(io::IO, @nospecialize(typ), idx::Int, used::Bool)
printstyled(io, "::", typ, color=(used ? :cyan : :light_black))
nothing
end
Expand Down Expand Up @@ -628,7 +628,7 @@ function show_ir_stmt(io::IO, code::Union{IRCode, CodeInfo}, idx::Int, line_info
if new_node_type === UNDEF # try to be robust against errors
printstyled(io, "::#UNDEF", color=:red)
elseif show_type
line_info_postprinter(IOContext(io, :idx => node_idx), new_node_type, node_idx in used)
line_info_postprinter(IOContext(io, :idx => node_idx), new_node_type, node_idx, node_idx in used)
end
println(io)
i += 1
Expand All @@ -643,7 +643,7 @@ function show_ir_stmt(io::IO, code::Union{IRCode, CodeInfo}, idx::Int, line_info
# This is an error, but can happen if passes don't update their type information
printstyled(io, "::#UNDEF", color=:red)
elseif show_type
line_info_postprinter(IOContext(io, :idx => idx), type, idx in used)
line_info_postprinter(IOContext(io, :idx => idx), type, idx, idx in used)
end
end
println(io)
Expand Down
6 changes: 3 additions & 3 deletions stdlib/InteractiveUtils/src/codeview.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ end

# displaying type warnings

function warntype_type_printer(io::IO, @nospecialize(ty), used::Bool)
function warntype_type_printer(io::IO, @nospecialize(ty), idx::Int, used::Bool)
used || return
str = "::$ty"
if !highlighting[:warntype]
Expand Down Expand Up @@ -120,13 +120,13 @@ function code_warntype(io::IO, @nospecialize(f), @nospecialize(t);
end
print(io, " ", slotnames[i])
if isa(slottypes, Vector{Any})
warntype_type_printer(io, slottypes[i], true)
warntype_type_printer(io, slottypes[i], 0, true)
end
println(io)
end
end
print(io, "Body")
warntype_type_printer(io, rettype, true)
warntype_type_printer(io, rettype, 0, true)
println(io)
irshow_config = Base.IRShow.IRShowConfig(lineprinter(src), warntype_type_printer)
Base.IRShow.show_ir(lambda_io, src, irshow_config)
Expand Down