Skip to content

Commit

Permalink
Merge pull request #15919 from JuliaLang/nl/dec
Browse files Browse the repository at this point in the history
Fix inference for string(::IntXX)
  • Loading branch information
vtjnash committed Apr 18, 2016
2 parents 707b7cc + 33720c4 commit 2aa5d4d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 2 additions & 0 deletions base/intfuncs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ ndigits(x::Integer) = ndigits(unsigned(abs(x)))

## integer to string functions ##

string(x::Union{Int8,Int16,Int32,Int64,Int128}) = dec(x)

function bin(x::Unsigned, pad::Int, neg::Bool)
i = neg + max(pad,sizeof(x)<<3-leading_zeros(x))
a = Array(UInt8,i)
Expand Down
4 changes: 0 additions & 4 deletions base/parse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,6 @@ function parse{T<:Integer}(::Type{T}, s::AbstractString, base::Integer)
end
parse{T<:Integer}(::Type{T}, s::AbstractString) = get(tryparse_internal(T, s, 0, true))

## stringifying integers more efficiently ##

string(x::Union{Int8,Int16,Int32,Int64,Int128}) = dec(x)

## string to float functions ##

tryparse(::Type{Float64}, s::ByteString) = ccall(:jl_try_substrtod, Nullable{Float64}, (Ptr{UInt8},Csize_t,Csize_t), s, 0, sizeof(s))
Expand Down
3 changes: 3 additions & 0 deletions test/intfuncs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,6 @@ let ptr = Ptr{Void}(typemax(UInt))
@test typeof(Ptr{Float64}(T(ptr))) == Ptr{Float64}
end
end

# issue #15911
@inferred string(1)

0 comments on commit 2aa5d4d

Please sign in to comment.