Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/styles/default/pretty.jl
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ function p_literal(
val = getsrcval(s.doc, s.offset:(s.offset+span(cst)-1))

if !is_str_or_cmd(cst)
if kind(cst) in KSet"Float Float32" && !startswith(val, "0x")
if kind(cst) in KSet"Float Float32" && !startswith(val, r"[+-]?0x")
float_suffix = if (fidx = findlast(==('f'), val)) === nothing
""
else
Expand Down
11 changes: 11 additions & 0 deletions test/issues.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1953,4 +1953,15 @@
sf = "using Foo: (..)"
@test fmt(s, 4, 100) == sf
end

@testset "921" begin
# These are floating point literals with hexadecimal significands. E.g. 0x1p1 is the
# float with with 0x1 as the significant and 1 as the exponent.
s = "0x1p1"
@test fmt(s) == s
s = "+0x1p1"
@test fmt(s) == s
s = "-0x1p1"
@test fmt(s) == s
end
end
Loading