Skip to content

Commit 890f34c

Browse files
authored
fix #36108, printing invalid numeric juxtapositions (#36122)
1 parent b49a0d5 commit 890f34c

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

base/show.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1342,7 +1342,8 @@ function show_unquoted(io::IO, ex::Expr, indent::Int, prec::Int, quote_level::In
13421342

13431343
# scalar multiplication (i.e. "100x")
13441344
elseif (func === :* &&
1345-
length(func_args)==2 && isa(func_args[1], Real) && isa(func_args[2], Symbol))
1345+
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')))
13461347
if func_prec <= prec
13471348
show_enclosed_list(io, '(', func_args, "", ')', indent, func_prec, quote_level)
13481349
else

test/show.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ end
138138
# basic expressions
139139
@test_repr "x + y"
140140
@test_repr "2e"
141+
@test_repr "2*e1"
142+
@test_repr "2*E1"
143+
@test_repr "2*f1"
144+
@test_repr "0x00*a"
141145
@test_repr "!x"
142146
@test_repr "f(1, 2, 3)"
143147
@test_repr "x = ~y"

0 commit comments

Comments
 (0)