From 2ac4b4fa97c29d7b2acf6f6541dc706398b6443d Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Thu, 18 Sep 2025 21:11:22 -0400 Subject: [PATCH] specialize show of `:` to make `reshape` trimmable --- base/essentials.jl | 4 ++++ contrib/juliac/juliac-trim-base.jl | 1 - test/trimming/trimmability.jl | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/base/essentials.jl b/base/essentials.jl index 62b880d4122ec..84b8f8999038c 100644 --- a/base/essentials.jl +++ b/base/essentials.jl @@ -1054,6 +1054,10 @@ struct Colon <: Function end const (:) = Colon() +function show(io::IO, ::Colon) + show_type_name(io, Colon.name) + print(io, "()") +end """ Val(c) diff --git a/contrib/juliac/juliac-trim-base.jl b/contrib/juliac/juliac-trim-base.jl index 1cf8224e4a8cd..3cb69dcc949be 100644 --- a/contrib/juliac/juliac-trim-base.jl +++ b/contrib/juliac/juliac-trim-base.jl @@ -77,7 +77,6 @@ end print(io, T.var.name) end end - show_type_name(io::IO, tn::Core.TypeName) = print(io, tn.name) # this function is not `--trim`-compatible if it resolves to a Varargs{...} specialization # and since it only has 1-argument methods this happens too often by default (just 2-3 args) setfield!(typeof(throw_eachindex_mismatch_indices).name, :max_args, Int32(5), :monotonic) diff --git a/test/trimming/trimmability.jl b/test/trimming/trimmability.jl index 041f3621216a6..209a27343d18d 100644 --- a/test/trimming/trimmability.jl +++ b/test/trimming/trimmability.jl @@ -48,5 +48,7 @@ function @main(args::Vector{String})::Cint catch end + Base.donotdelete(reshape([1,2,3],:,1,1)) + return 0 end