Skip to content

Commit

Permalink
Implement convert(::Type{String}, x::Symbol)
Browse files Browse the repository at this point in the history
This is the underlying support for calling String(::Symbol).
Bug fix for issue #16997
  • Loading branch information
dbeach24 committed Sep 18, 2016
1 parent a648f4a commit 710561d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions base/strings/basic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ convert(::Type{Array{UInt8}}, s::AbstractString) = String(s).data
convert(::Type{String}, s::AbstractString) = String(s)
convert(::Type{Vector{Char}}, s::AbstractString) = collect(s)
convert(::Type{Symbol}, s::AbstractString) = Symbol(s)
convert(::Type{String}, s::Symbol) = unsafe_wrap(String, Cstring(s))

## generic supplied functions ##

Expand Down
1 change: 1 addition & 0 deletions test/strings/basic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ let
# make symbol with invalid char
sym = Symbol(Char(0xdcdb))
@test string(sym) == string(Char(0xdcdb))
@test String(sym) == string(Char(0xdcdb))
@test expand(sym) === sym
res = string(parse(string(Char(0xdcdb)," = 1"),1,raise=false)[1])
@test res == """\$(Expr(:error, "invalid character \\\"\\udcdb\\\"\"))"""
Expand Down

0 comments on commit 710561d

Please sign in to comment.