Skip to content

Commit 2aa5d4d

Browse files
committed
Merge pull request #15919 from JuliaLang/nl/dec
Fix inference for string(::IntXX)
2 parents 707b7cc + 33720c4 commit 2aa5d4d

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

base/intfuncs.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@ ndigits(x::Integer) = ndigits(unsigned(abs(x)))
228228

229229
## integer to string functions ##
230230

231+
string(x::Union{Int8,Int16,Int32,Int64,Int128}) = dec(x)
232+
231233
function bin(x::Unsigned, pad::Int, neg::Bool)
232234
i = neg + max(pad,sizeof(x)<<3-leading_zeros(x))
233235
a = Array(UInt8,i)

base/parse.jl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,6 @@ function parse{T<:Integer}(::Type{T}, s::AbstractString, base::Integer)
145145
end
146146
parse{T<:Integer}(::Type{T}, s::AbstractString) = get(tryparse_internal(T, s, 0, true))
147147

148-
## stringifying integers more efficiently ##
149-
150-
string(x::Union{Int8,Int16,Int32,Int64,Int128}) = dec(x)
151-
152148
## string to float functions ##
153149

154150
tryparse(::Type{Float64}, s::ByteString) = ccall(:jl_try_substrtod, Nullable{Float64}, (Ptr{UInt8},Csize_t,Csize_t), s, 0, sizeof(s))

test/intfuncs.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,6 @@ let ptr = Ptr{Void}(typemax(UInt))
135135
@test typeof(Ptr{Float64}(T(ptr))) == Ptr{Float64}
136136
end
137137
end
138+
139+
# issue #15911
140+
@inferred string(1)

0 commit comments

Comments
 (0)