From bb7c674d339a82d5bf05f7cad0657c0c285d5053 Mon Sep 17 00:00:00 2001 From: Zentrik Date: Tue, 22 Aug 2023 16:07:14 +0100 Subject: [PATCH 1/2] Check type name is a type --- TypedSyntax/src/show.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TypedSyntax/src/show.jl b/TypedSyntax/src/show.jl index 91244972..79361ca5 100644 --- a/TypedSyntax/src/show.jl +++ b/TypedSyntax/src/show.jl @@ -99,7 +99,7 @@ function type_annotation_mode(node, @nospecialize(T); type_annotations::Bool, hi type_annotate = is_show_annotation(T; type_annotations, hide_type_stable) pre = pre2 = post = "" if type_annotate - if T <: Type + if T isa Type && T <: Type # Don't annotate `String::Type{String}` if replace(sourcetext(node), r"\s" => "") == replace(sprint(show, T.parameters[1]), r"\s" => "") return false, pre, pre2, post From b38c7df9fd454ea88c43caf9e9ade8ec7e5a6e98 Mon Sep 17 00:00:00 2001 From: Zentrik Date: Tue, 22 Aug 2023 16:31:02 +0100 Subject: [PATCH 2/2] Add test --- TypedSyntax/test/runtests.jl | 9 +++++++++ TypedSyntax/test/test_module.jl | 3 +++ 2 files changed, 12 insertions(+) diff --git a/TypedSyntax/test/runtests.jl b/TypedSyntax/test/runtests.jl index b859dd3a..bc880f3a 100644 --- a/TypedSyntax/test/runtests.jl +++ b/TypedSyntax/test/runtests.jl @@ -641,6 +641,15 @@ include("test_module.jl") # issue #435 tsnc = copy(tsn) @test isa(tsnc, TypedSyntaxNode) + + # issue 487 + m = which(TSN.f487, (Int,)) + src, rt = getsrc(TSN.f487, (Int,)) + rt = Core.Const(1) + tsn, _ = TypedSyntax.tsn_and_mappings(m, src, rt) + @test_nowarn str = sprint(tsn; context=:color=>false) do io, obj + printstyled(io, obj; hide_type_stable=false) + end end if parse(Bool, get(ENV, "CI", "false")) diff --git a/TypedSyntax/test/test_module.jl b/TypedSyntax/test/test_module.jl index 570e22dc..2cfc430b 100644 --- a/TypedSyntax/test/test_module.jl +++ b/TypedSyntax/test/test_module.jl @@ -234,4 +234,7 @@ MyDict{T} = Dict{T,Any} f482a(x) = MyDict{String}(x) f482b(x) = Dict{String,Any}(x) +# Issue 487 +f487(x) = 1 + end