Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-7224] String.init(_ substring: Substring) is failable on Linux. #49772

Open
louisdh opened this issue Mar 18, 2018 · 2 comments
Open

[SR-7224] String.init(_ substring: Substring) is failable on Linux. #49772

louisdh opened this issue Mar 18, 2018 · 2 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. standard library Area: Standard library umbrella

Comments

@louisdh
Copy link
Contributor

louisdh commented Mar 18, 2018

Previous ID SR-7224
Radar None
Original Reporter @louisdh
Type Bug
Environment

Apple Swift version 4.0.3 (swiftlang-900.0.74.1 clang-900.0.39.2)

Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels Bug
Assignee @milseman
Priority Medium

md5: 4de3fa3865c018bf532130f3b1ff7164

Issue Description:

Initializing a String from a Substring is non-failable on iOS, macOS, ...
On Linux, however, this is failable.

For example, the following code compiles when targeting macOS, but gives a compile error on Linux:

let foo = "Hello world"

let bar = String(foo[foo.startIndex..<foo.endIndex])

// Error on Linux: "value of optional type 'String?' not unwrapped; did you mean to use '!' or '?'?"
if bar.hasPrefix("") {
    // do something
}
@belkadan
Copy link
Contributor

@milseman, any idea what's going on here?

@milseman
Copy link
Mannequin

milseman mannequin commented Mar 19, 2018

No idea why. CC Lance (JIRA User) who has been looking at some of the String.init mismatch here

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. standard library Area: Standard library umbrella
Projects
None yet
Development

No branches or pull requests

2 participants