Skip to content

Commit 626777c

Browse files
JeffBezansonKristofferC
authored andcommitted
fix #37282, printing juxtaposition of 0 confusion with hex,bin,oct literals (#37308)
(cherry picked from commit f896006)
1 parent 987afb2 commit 626777c

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

base/show.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1339,7 +1339,10 @@ function show_unquoted(io::IO, ex::Expr, indent::Int, prec::Int, quote_level::In
13391339
# scalar multiplication (i.e. "100x")
13401340
elseif (func === :* &&
13411341
length(func_args) == 2 && isa(func_args[1], Union{Int, Int64, Float32, Float64}) &&
1342-
isa(func_args[2], Symbol) && !in(string(func_args[2])[1], ('e', 'E', 'f')))
1342+
isa(func_args[2], Symbol) &&
1343+
!in(string(func_args[2]::Symbol)[1], ('e', 'E', 'f', (func_args[1] == 0 && func_args[1] isa Integer ?
1344+
# don't juxtapose 0 with b, o, x
1345+
('b', 'o', 'x') : ())...)))
13431346
if func_prec <= prec
13441347
show_enclosed_list(io, '(', func_args, "", ')', indent, func_prec, quote_level)
13451348
else

test/show.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,10 @@ for ex in [Expr(:call, :f, Expr(:(=), :x, 1)),
235235
Expr(:call, :+, :n, Expr(:kw, :x, 1)),
236236
:((a=1,; $(Expr(:(=), :x, 2)))),
237237
:(($(Expr(:(=), :a, 1)),; x = 2)),
238-
Expr(:tuple, Expr(:parameters))]
238+
Expr(:tuple, Expr(:parameters)),
239+
Expr(:call, :*, 0, :x01),
240+
Expr(:call, :*, 0, :b01),
241+
Expr(:call, :*, 0, :o01)]
239242
@test eval(Meta.parse(repr(ex))) == ex
240243
end
241244

0 commit comments

Comments
 (0)