From c14693e2471245a74b190b2db5526dbb86c2213a Mon Sep 17 00:00:00 2001 From: Kristoffer Carlsson Date: Tue, 23 Jun 2020 21:16:55 +0200 Subject: [PATCH] fix showing methods with unicode gensymed variable names (#36396) --- base/methodshow.jl | 2 +- test/show.jl | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/base/methodshow.jl b/base/methodshow.jl index 2762acfb52a5cd..ea5f14f9c1ab18 100644 --- a/base/methodshow.jl +++ b/base/methodshow.jl @@ -13,7 +13,7 @@ function argtype_decl(env, n, sig::DataType, i::Int, nargs, isva::Bool) # -> (ar s = string(n) i = findfirst(isequal('#'), s) if i !== nothing - s = s[1:i-1] + s = s[1:prevind(s, i)] end if t === Any && !isempty(s) return s, "" diff --git a/test/show.jl b/test/show.jl index ac628739fd5bf1..1a398974addd17 100644 --- a/test/show.jl +++ b/test/show.jl @@ -1985,3 +1985,12 @@ end @test sprint(show, skipmissing([1,2,missing])) == "skipmissing(Union{Missing, $Int}[1, 2, missing])" @test sprint(show, skipmissing((missing,1.0,'a'))) == "skipmissing((missing, 1.0, 'a'))" end + +@testset "unicode in method table" begin + αsym = gensym(:α) + ℓsym = gensym(:ℓ) + eval(:(foo($αsym) = $αsym)) + eval(:(bar($ℓsym) = $ℓsym)) + @test contains(string(methods(foo)), "foo(α)") + @test contains(string(methods(bar)), "bar(ℓ)") +end