Skip to content

[SR-598] String initialized with [Any] causes runtime crash #43215

Closed
@jepers

Description

@jepers
Previous ID SR-598
Radar None
Original Reporter @jepers
Type Bug
Status Closed
Resolution Cannot Reproduce
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, TypeChecker
Assignee @jepers
Priority Medium

md5: 28a457a2eebf994c177f8f5e2ca4a7d3

Issue Description:

I have only tested this in swift-2.2-SNAPSHOT-2016-01-06-a-osx.pkg
(So maybe it's fixed in current master)

This program (cmd line prj, no imports) compiles fine but the resulting binary crashes at runtime:

let a: [Any] = [] // (Could as well be eg [1, "two"])
let s = String(a) // <-- Runtime crash here.
print(s)

Jumping to definition on the init of String.init(a) takes me here:

    /// Create an instance containing `characters`.
    public init<S : SequenceType where S.Generator.Element == Character>(_ characters: S)

which seems a bit strange (since the elements of a are not Characters).

Metadata

Metadata

Assignees

Labels

bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselftype checkerArea → compiler: Semantic analysis

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions