Skip to content

Commit c360a58

Browse files
authored
Fixed inference on String and Symbol causing invalidations in show.jl (#44091)
1 parent fed4544 commit c360a58

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

base/show.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,7 +1420,7 @@ julia> Meta.ispostfixoperator(Symbol("'")), Meta.ispostfixoperator(Symbol("'ᵀ"
14201420
```
14211421
"""
14221422
function ispostfixoperator(s::Union{Symbol,AbstractString})
1423-
s = String(s)
1423+
s = String(s)::String
14241424
return startswith(s, '\'') && all(is_op_suffix_char, SubString(s, 2))
14251425
end
14261426

@@ -1778,7 +1778,7 @@ function show_unquoted(io::IO, ex::Expr, indent::Int, prec::Int, quote_level::In
17781778
# dot (i.e. "x.y"), but not compact broadcast exps
17791779
if head === :(.) && (nargs != 2 || !is_expr(args[2], :tuple))
17801780
# standalone .op
1781-
if nargs == 1 && args[1] isa Symbol && isoperator(args[1])
1781+
if nargs == 1 && args[1] isa Symbol && isoperator(args[1]::Symbol)
17821782
print(io, "(.", args[1], ")")
17831783
elseif nargs == 2 && is_quoted(args[2])
17841784
item = args[1]
@@ -1867,10 +1867,10 @@ function show_unquoted(io::IO, ex::Expr, indent::Int, prec::Int, quote_level::In
18671867
elseif (head === Symbol("'") && nargs == 1) || (
18681868
# ' with unicode suffix is a call expression
18691869
head === :call && nargs == 2 && args[1] isa Symbol &&
1870-
ispostfixoperator(args[1]) && args[1] !== Symbol("'")
1870+
ispostfixoperator(args[1]::Symbol) && args[1]::Symbol !== Symbol("'")
18711871
)
18721872
op, arg1 = head === Symbol("'") ? (head, args[1]) : (args[1], args[2])
1873-
if isa(arg1, Expr) || (isa(arg1, Symbol) && isoperator(arg1))
1873+
if isa(arg1, Expr) || (isa(arg1, Symbol) && isoperator(arg1::Symbol))
18741874
show_enclosed_list(io, '(', [arg1::Union{Expr, Symbol}], ", ", ')', indent, 0)
18751875
else
18761876
show_unquoted(io, arg1, indent, 0, quote_level)
@@ -1918,7 +1918,7 @@ function show_unquoted(io::IO, ex::Expr, indent::Int, prec::Int, quote_level::In
19181918
elseif func_prec > 0 # is a binary operator
19191919
na = length(func_args)
19201920
if (na == 2 || (na > 2 && isa(func, Symbol) && func in (:+, :++, :*)) || (na == 3 && func === :(:))) &&
1921-
all(!isa(a, Expr) || a.head !== :... for a in func_args)
1921+
all(a -> !isa(a, Expr) || a.head !== :..., func_args)
19221922
sep = func === :(:) ? "$func" : " $func "
19231923

19241924
if func_prec <= prec

0 commit comments

Comments
 (0)