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-747] CChar("\n") returns nil #43362

Open
gribozavr opened this issue Feb 16, 2016 · 3 comments
Open

[SR-747] CChar("\n") returns nil #43362

gribozavr opened this issue Feb 16, 2016 · 3 comments

Comments

@gribozavr
Copy link
Collaborator

@gribozavr gribozavr commented Feb 16, 2016

Previous ID SR-747
Radar rdar://problem/31414908
Original Reporter @gribozavr
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels Bug, AffectsABI
Assignee None
Priority Medium

md5: e6b160cd6c1db2119a0067532da588eb

Issue Description:

CChar("\n") returns nil. This is because CChar is a typealias for Int8, and Int8 has an initializer that parses numbers from strings.

@swift-ci
Copy link
Collaborator

@swift-ci swift-ci commented Apr 28, 2016

Comment by Andrew Hoos (JIRA)

Could this be solved by an extension on CChar that overrides init?

@bob-wilson
Copy link

@bob-wilson bob-wilson commented Apr 3, 2017

@swift-ci create

@swift-ci
Copy link
Collaborator

@swift-ci swift-ci commented Mar 4, 2019

Comment by Michael Verges (JIRA)

I don't think overriding the init in an extension is the right approach. Because CChar is a typealias of UInt8, calling UInt8("\n") should return the same value as CChar("\n"). Furthermore, CUnsignedChar, CSignedChar, CChar16, and CChar32 should also provide the same value. If this is to be changed, I think it should be done at the root, wherever Builtin converts the String to an Int (not sure where this happens). Also, what do you expect CChar("\n") return? nil seems expected as it does for every other non-integer String.

@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
Projects
None yet
Development

No branches or pull requests

3 participants