Skip to content

Commit ada29c2

Browse files
author
Michael Abbott
committed
bold function names in stacktrace
1 parent 37b8805 commit ada29c2

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

base/show.jl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2028,7 +2028,7 @@ function show_signature_function(io::IO, @nospecialize(ft), demangle=false, farg
20282028
if ft <: Function && isa(uw, DataType) && isempty(uw.parameters) &&
20292029
isdefined(uw.name.module, uw.name.mt.name) &&
20302030
ft == typeof(getfield(uw.name.module, uw.name.mt.name))
2031-
print(io, (demangle ? demangle_function_name : identity)(uw.name.mt.name))
2031+
print_within_stacktrace(io, (demangle ? demangle_function_name : identity)(uw.name.mt.name), bold=true)
20322032
elseif isa(ft, DataType) && ft.name === Type.body.name &&
20332033
(f = ft.parameters[1]; !isa(f, TypeVar))
20342034
uwf = unwrap_unionall(f)
@@ -2040,19 +2040,20 @@ function show_signature_function(io::IO, @nospecialize(ft), demangle=false, farg
20402040
if html
20412041
print(io, "($fargname::<b>", ft, "</b>)")
20422042
else
2043-
print(io, "($fargname::", ft, ")")
2043+
print_within_stacktrace(io, "($fargname::", ft, ")", bold=true)
20442044
end
20452045
end
20462046
nothing
20472047
end
20482048

2049-
function print_within_stacktrace(io, s...; color, bold=false)
2049+
function print_within_stacktrace(io, s...; color=:normal, bold=false)
20502050
if get(io, :backtrace, false)::Bool
20512051
printstyled(io, s...; color, bold)
20522052
else
20532053
print(io, s...)
20542054
end
20552055
end
2056+
20562057
function show_tuple_as_call(io::IO, name::Symbol, sig::Type, demangle=false, kwargs=nothing, argnames=nothing)
20572058
# print a method signature tuple for a lambda definition
20582059
if sig === Tuple
@@ -2091,15 +2092,15 @@ function show_tuple_as_call(io::IO, name::Symbol, sig::Type, demangle=false, kwa
20912092
print_type_stacktrace(io, t)
20922093
end
20932094
end
2094-
print(io, ")")
2095+
print_within_stacktrace(io, ")", bold=true)
20952096
show_method_params(io, tv)
20962097
nothing
20972098
end
20982099

20992100
function print_type_stacktrace(io, type; color=:normal)
21002101
str = sprint(show, type, context=io)
21012102
i = findfirst('{', str)
2102-
if isnothing(i)
2103+
if isnothing(i) || !get(io, :backtrace, false)::Bool
21032104
printstyled(io, str; color=color)
21042105
else
21052106
printstyled(io, str[1:i-1]; color=color)

base/stacktraces.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ function show_spec_linfo(io::IO, frame::StackFrame)
217217
elseif frame.func === top_level_scope_sym
218218
print(io, "top-level scope")
219219
else
220-
print(io, Base.demangle_function_name(string(frame.func)))
220+
Base.print_within_stacktrace(io, Base.demangle_function_name(string(frame.func)), bold=true)
221221
end
222222
elseif linfo isa MethodInstance
223223
def = linfo.def

0 commit comments

Comments
 (0)