diff --git a/TypedSyntax/src/show.jl b/TypedSyntax/src/show.jl index 79361ca5..d1965f95 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 isa Type && T <: Type + if T isa Type && T <: Type && T !== Union{} && isassigned(T.parameters, 1) # 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 diff --git a/TypedSyntax/test/runtests.jl b/TypedSyntax/test/runtests.jl index bc880f3a..c192744d 100644 --- a/TypedSyntax/test/runtests.jl +++ b/TypedSyntax/test/runtests.jl @@ -650,6 +650,16 @@ include("test_module.jl") @test_nowarn str = sprint(tsn; context=:color=>false) do io, obj printstyled(io, obj; hide_type_stable=false) end + + # issue 491 + tsn = TypedSyntaxNode(+, (Int, Int)) # need a node, not important what it is + @test_nowarn TypedSyntax.type_annotation_mode(tsn, Union{}; type_annotations=true, hide_type_stable=false) + + # issue 492 + tsn = TypedSyntaxNode(Base._tuple_unique_fieldtypes, (Any,)) + @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"))