Skip to content

Commit 6b2ffd3

Browse files
authored
Fix some invalidations from extending ==(::Any, ::SomeType) (#36255)
1 parent 1e76111 commit 6b2ffd3

File tree

5 files changed

+33
-28
lines changed

5 files changed

+33
-28
lines changed

base/errorshow.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -636,8 +636,8 @@ function show_backtrace(io::IO, t::Vector)
636636
isempty(filtered) && return
637637

638638
if length(filtered) == 1 && StackTraces.is_top_level_frame(filtered[1][1])
639-
f = filtered[1][1]
640-
if f.line == 0 && f.file == Symbol("")
639+
f = filtered[1][1]::StackFrame
640+
if f.line == 0 && f.file === Symbol("")
641641
# don't show a single top-level frame with no location info
642642
return
643643
end
@@ -693,7 +693,7 @@ function _simplify_include_frames(trace)
693693
# Hack: allow `mod==nothing` as a workaround for inlined functions.
694694
# TODO: Fix this by improving debug info.
695695
if mod in (Base,Core,nothing) && 1+first_ignored-i <= 5
696-
if frame.func == :eval
696+
if frame.func === :eval
697697
kept_frames[i:first_ignored] .= false
698698
first_ignored = nothing
699699
end

base/meta.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ true
6363
"""
6464
isexpr(@nospecialize(ex), head::Symbol) = isa(ex, Expr) && ex.head === head
6565
isexpr(@nospecialize(ex), heads::Union{Set,Vector,Tuple}) = isa(ex, Expr) && in(ex.head, heads)
66-
isexpr(@nospecialize(ex), heads, n::Int) = isexpr(ex, heads) && length(ex.args) == n
66+
isexpr(@nospecialize(ex), heads, n::Int) = isexpr(ex, heads) && length((ex::Expr).args) == n
6767

6868
"""
6969
Meta.show_sexpr([io::IO,], ex)

base/show.jl

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,7 @@ function operator_associativity(s::Symbol)
965965
end
966966

967967
is_expr(@nospecialize(ex), head::Symbol) = isa(ex, Expr) && (ex.head === head)
968-
is_expr(@nospecialize(ex), head::Symbol, n::Int) = is_expr(ex, head) && length(ex.args) == n
968+
is_expr(@nospecialize(ex), head::Symbol, n::Int) = is_expr(ex, head) && length((ex::Expr).args) == n
969969

970970
is_quoted(ex) = false
971971
is_quoted(ex::QuoteNode) = true
@@ -1031,13 +1031,15 @@ function show_list(io::IO, items, sep, indent::Int, prec::Int=0, quote_level::In
10311031
!first && print(io, sep)
10321032
parens = !is_quoted(item) &&
10331033
(first && prec >= prec_power &&
1034-
((item isa Expr && item.head === :call && item.args[1] in uni_ops) ||
1034+
((item isa Expr && item.head === :call && (callee = item.args[1]; isa(callee, Symbol) && callee in uni_ops)) ||
10351035
(item isa Real && item < 0))) ||
10361036
(enclose_operators && item isa Symbol && isoperator(item))
10371037
parens && print(io, '(')
10381038
if kw && is_expr(item, :kw, 2)
1039+
item = item::Expr
10391040
show_unquoted(io, Expr(:(=), item.args[1], item.args[2]), indent, parens ? 0 : prec, quote_level)
10401041
elseif kw && is_expr(item, :(=), 2)
1042+
item = item::Expr
10411043
show_unquoted_expr_fallback(io, item, indent, quote_level)
10421044
else
10431045
show_unquoted(io, item, indent, parens ? 0 : prec, quote_level)
@@ -1261,7 +1263,7 @@ function show_unquoted(io::IO, ex::Expr, indent::Int, prec::Int, quote_level::In
12611263
# .
12621264
print(io, '.')
12631265
# item
1264-
parens = !(field isa Symbol) || (field in quoted_syms)
1266+
parens = !(field isa Symbol) || (field::Symbol in quoted_syms)
12651267
quoted = parens || isoperator(field)
12661268
quoted && print(io, ':')
12671269
parens && print(io, '(')
@@ -1284,13 +1286,14 @@ function show_unquoted(io::IO, ex::Expr, indent::Int, prec::Int, quote_level::In
12841286
elseif head === :tuple
12851287
print(io, "(")
12861288
if nargs > 0 && is_expr(args[1], :parameters)
1289+
arg1 = args[1]::Expr
12871290
show_list(io, args[2:end], ", ", indent, 0, quote_level)
12881291
nargs == 2 && print(io, ',')
12891292
print(io, ";")
1290-
if !isempty(args[1].args)
1293+
if !isempty(arg1.args)
12911294
print(io, " ")
12921295
end
1293-
show_list(io, args[1].args, ", ", indent, 0, quote_level, false, true)
1296+
show_list(io, arg1.args, ", ", indent, 0, quote_level, false, true)
12941297
else
12951298
show_list(io, args, ", ", indent, 0, quote_level)
12961299
nargs == 1 && print(io, ',')
@@ -1331,7 +1334,7 @@ function show_unquoted(io::IO, ex::Expr, indent::Int, prec::Int, quote_level::In
13311334
func = args[1]
13321335
fname = isa(func, GlobalRef) ? func.name : func
13331336
func_prec = operator_precedence(fname)
1334-
if func_prec > 0 || fname in uni_ops
1337+
if func_prec > 0 || (isa(fname, Symbol) && fname in uni_ops)
13351338
func = fname
13361339
end
13371340
func_args = args[2:end]
@@ -1343,7 +1346,7 @@ function show_unquoted(io::IO, ex::Expr, indent::Int, prec::Int, quote_level::In
13431346
# scalar multiplication (i.e. "100x")
13441347
elseif (func === :* &&
13451348
length(func_args) == 2 && isa(func_args[1], Union{Int, Int64, Float32, Float64}) &&
1346-
isa(func_args[2], Symbol) && !in(string(func_args[2])[1], ('e', 'E', 'f')))
1349+
isa(func_args[2], Symbol) && !in(string(func_args[2]::Symbol)[1], ('e', 'E', 'f')))
13471350
if func_prec <= prec
13481351
show_enclosed_list(io, '(', func_args, "", ')', indent, func_prec, quote_level)
13491352
else
@@ -1363,7 +1366,7 @@ function show_unquoted(io::IO, ex::Expr, indent::Int, prec::Int, quote_level::In
13631366
# binary operator (i.e. "x + y")
13641367
elseif func_prec > 0 # is a binary operator
13651368
na = length(func_args)
1366-
if (na == 2 || (na > 2 && func in (:+, :++, :*)) || (na == 3 && func === :(:))) &&
1369+
if (na == 2 || (na > 2 && isa(func, Symbol) && func in (:+, :++, :*)) || (na == 3 && func === :(:))) &&
13671370
all(!isa(a, Expr) || a.head !== :... for a in func_args)
13681371
sep = func === :(:) ? "$func" : " $func "
13691372

@@ -1431,7 +1434,7 @@ function show_unquoted(io::IO, ex::Expr, indent::Int, prec::Int, quote_level::In
14311434
# function calls need to transform the function from :call to :calldecl
14321435
# so that operators are printed correctly
14331436
elseif head === :function && nargs==2 && is_expr(args[1], :call)
1434-
show_block(IOContext(io, beginsym=>false), head, Expr(:calldecl, args[1].args...), args[2], indent, quote_level)
1437+
show_block(IOContext(io, beginsym=>false), head, Expr(:calldecl, (args[1]::Expr).args...), args[2], indent, quote_level)
14351438
print(io, "end")
14361439

14371440
elseif (head === :function || head === :macro) && nargs == 1
@@ -1443,8 +1446,8 @@ function show_unquoted(io::IO, ex::Expr, indent::Int, prec::Int, quote_level::In
14431446
iob = IOContext(io, beginsym=>false)
14441447
show_unquoted(iob, args[1], indent, -1, quote_level)
14451448
print(io, " do ")
1446-
show_list(iob, args[2].args[1].args, ", ", 0, 0, quote_level)
1447-
for stmt in args[2].args[2].args
1449+
show_list(iob, (((args[2]::Expr).args[1])::Expr).args, ", ", 0, 0, quote_level)
1450+
for stmt in (((args[2]::Expr).args[2])::Expr).args
14481451
print(io, '\n', " "^(indent + indent_width))
14491452
show_unquoted(iob, stmt, indent + indent_width, -1, quote_level)
14501453
end
@@ -1463,10 +1466,11 @@ function show_unquoted(io::IO, ex::Expr, indent::Int, prec::Int, quote_level::In
14631466
elseif (head === :if || head === :elseif) && nargs == 3
14641467
iob = IOContext(io, beginsym=>false)
14651468
show_block(iob, head, args[1], args[2], indent, quote_level)
1466-
if isa(args[3],Expr) && args[3].head === :elseif
1467-
show_unquoted(iob, args[3], indent, prec, quote_level)
1469+
arg3 = args[3]
1470+
if isa(arg3, Expr) && arg3.head === :elseif
1471+
show_unquoted(iob, arg3::Expr, indent, prec, quote_level)
14681472
else
1469-
show_block(iob, "else", args[3], indent, quote_level)
1473+
show_block(iob, "else", arg3, indent, quote_level)
14701474
print(io, "end")
14711475
end
14721476

@@ -1562,7 +1566,8 @@ function show_unquoted(io::IO, ex::Expr, indent::Int, prec::Int, quote_level::In
15621566
show_sym(io, arg1, allow_macroname=true)
15631567
elseif arg1 isa GlobalRef
15641568
show_globalref(io, arg1, allow_macroname=true)
1565-
elseif is_expr(arg1, :(.)) && length(arg1.args) == 2
1569+
elseif is_expr(arg1, :(.)) && length((arg1::Expr).args) == 2
1570+
arg1 = arg1::Expr
15661571
m = arg1.args[1]
15671572
if m isa Symbol || m isa GlobalRef || is_expr(m, :(.), 2)
15681573
show_unquoted(io, m)
@@ -1573,9 +1578,9 @@ function show_unquoted(io::IO, ex::Expr, indent::Int, prec::Int, quote_level::In
15731578
end
15741579
print(io, '.')
15751580
if is_expr(arg1.args[2], :quote)
1576-
mname = arg1.args[2].args[1]
1581+
mname = (arg1.args[2]::Expr).args[1]
15771582
else
1578-
mname = arg1.args[2].value
1583+
mname = (arg1.args[2]::QuoteNode).value
15791584
end
15801585
if mname isa Symbol
15811586
show_sym(io, mname, allow_macroname=true)
@@ -1593,10 +1598,10 @@ function show_unquoted(io::IO, ex::Expr, indent::Int, prec::Int, quote_level::In
15931598
iob = IOContext(io, beginsym=>false)
15941599
show_block(iob, "try", args[1], indent, quote_level)
15951600
if is_expr(args[3], :block)
1596-
show_block(iob, "catch", args[2] === false ? Any[] : args[2], args[3], indent, quote_level)
1601+
show_block(iob, "catch", args[2] === false ? Any[] : args[2], args[3]::Expr, indent, quote_level)
15971602
end
15981603
if nargs >= 4 && is_expr(args[4], :block)
1599-
show_block(iob, "finally", Any[], args[4], indent, quote_level)
1604+
show_block(iob, "finally", Any[], args[4]::Expr, indent, quote_level)
16001605
end
16011606
print(io, "end")
16021607

@@ -1627,9 +1632,9 @@ function show_unquoted(io::IO, ex::Expr, indent::Int, prec::Int, quote_level::In
16271632

16281633
elseif head === :quote && nargs == 1 && isa(args[1], Symbol)
16291634
show_unquoted_quote_expr(IOContext(io, beginsym=>false), args[1]::Symbol, indent, 0, quote_level+1)
1630-
elseif head === :quote && !get(io, :unquote_fallback, true)
1635+
elseif head === :quote && !(get(io, :unquote_fallback, true)::Bool)
16311636
if nargs == 1 && is_expr(args[1], :block)
1632-
show_block(IOContext(io, beginsym=>false), "quote", Expr(:quote, args[1].args...), indent,
1637+
show_block(IOContext(io, beginsym=>false), "quote", Expr(:quote, (args[1]::Expr).args...), indent,
16331638
quote_level+1)
16341639
print(io, "end")
16351640
elseif nargs == 1

stdlib/Distributed/src/clusterserialize.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ end
143143
# d) is a bits type
144144
function syms_2b_sent(s::ClusterSerializer, identifier)
145145
lst = Symbol[]
146-
check_syms = get(s.glbs_in_tnobj, identifier, [])
146+
check_syms = get(s.glbs_in_tnobj, identifier, Symbol[])
147147
for sym in check_syms
148148
v = getfield(Main, sym)
149149

stdlib/REPL/src/LineEdit.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ prompt_string(f::Function) = Base.invokelatest(f)
378378

379379
refresh_multi_line(s::ModeState; kw...) = refresh_multi_line(terminal(s), s; kw...)
380380
refresh_multi_line(termbuf::TerminalBuffer, s::ModeState; kw...) = refresh_multi_line(termbuf, terminal(s), s; kw...)
381-
refresh_multi_line(termbuf::TerminalBuffer, term, s::ModeState; kw...) = (@assert term == terminal(s); refresh_multi_line(termbuf,s; kw...))
381+
refresh_multi_line(termbuf::TerminalBuffer, term, s::ModeState; kw...) = (@assert term === terminal(s); refresh_multi_line(termbuf,s; kw...))
382382

383383
function refresh_multi_line(termbuf::TerminalBuffer, terminal::UnixTerminal, buf::IOBuffer,
384384
state::InputAreaState, prompt = "";
@@ -777,7 +777,7 @@ function edit_insert_newline(s::PromptState, align::Int = 0 - options(s).auto_in
777777
#else
778778
# align = 0
779779
end
780-
align < 0 && (align = 0)
780+
align < 0 && (align = 0)
781781
edit_insert(buf, '\n' * ' '^align)
782782
refresh_line(s)
783783
# updating s.last_newline should happen after refresh_line(s) which can take

0 commit comments

Comments
 (0)