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-13407] Can't init Scalar with 9992 in enum #55848
Comments
This behaves as intended. CharOrSectionMarkerScalar.Char(Unicode.Scalar(9992)) For this example, the type of the literal ends up being CharOrSectionMarkerScalar.Char(Unicode.Scalar(9992)!) For this example, a failable initializer is used due to the outer |
> Since 9992 is a legal parameter, it should return a legal value,not Some<Unicode.Scalar> I don't understand what you mean by "legal parameter". If you look at the initializers for 1. init(UInt8)
2. init(Unicode.Scalar)
3. init?(UInt32)
4. init?(UInt16)
5. init?(Int)
6. init(unicodeScalarLiteral: Unicode.Scalar)
7. init?(String) As I said above, in the case with a force-unwrap, initializer 5 is selected (which has a > Moreover, the following error message is more appropriate. The reason you are seeing different error messages is because Could you clarify what the central issue is?
|
Comment by bohong sun (JIRA) 1、The overflow diagnostic is difficult to understand. We could make it more understandable. 2、9992 is a valid Unicode code point
And https://developer.apple.com/documentation/swift/unicode/scalar/2905753-init lists the legal range
|
> Integer literal '9992' overflows when stored into 'UInt8' Point taken, I've filed SR-13429 to improve that. > 9992 is a valid Unicode code point Sure, that's why the initializer succeeds and returns |
Attachment: Download
Environment
Xcode 11.5
Additional Detail from JIRA
md5: 633333f39caf6549a04da338eaccb904
Issue Description:
```
{ case Paragraph case Char(Unicode.Scalar) case Chapter }
```
Integer literal '9992' overflows when stored into 'UInt8'
The follow code work well.
```
CharOrSectionMarkerScalar.Char(Unicode.Scalar(9992)!);
```
The text was updated successfully, but these errors were encountered: