Skip to content

Commit 2309198

Browse files
reinstate "useless" String() inner constructor (#16212)
1 parent 280310d commit 2309198

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

base/boot.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ abstract DirectIndexString <: AbstractString
220220

221221
immutable String <: AbstractString
222222
data::Array{UInt8,1}
223+
# required to make String("foo") work (#15120):
224+
String(d::Array{UInt8,1}) = new(d)
223225
end
224226

225227
include(fname::String) = ccall(:jl_load_, Any, (Any,), fname)

test/strings/basic.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# This file is a part of Julia. License is MIT: http://julialang.org/license
22

3+
# constructors
4+
@test String([0x61,0x62,0x63,0x21]) == "abc!"
5+
@test String("abc!") == "abc!"
6+
37
# {starts,ends}with
48
@test startswith("abcd", 'a')
59
@test startswith("abcd", "a")

0 commit comments

Comments
 (0)