-
Notifications
You must be signed in to change notification settings - Fork 10.5k
SE-0067 - Failable initializers for Numeric Types #2742
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
Conversation
Is there a test suite around this stuff that I'm missing? |
init<Source: Integer>(_ value: Source) | ||
|
||
/// Fails if the argument cannot be exactly represented. | ||
init?<Source: Integer>(exactly value: Source) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please restore this comment. The initializers should be generic.
Thank you! The tests should go into |
@swift-ci Please test |
@swift-ci Please test |
@ultramiraculous Could you take a look at the build failures? Do you think they are related? |
They don't appear to be related to my changes, but I've said that before and learned my lesson. It looks like there's unused results in Foundation? (Was SE-0047 completed at some point?) |
Quite possibly so, but unused results should only be warnings. In this case, we're failing the swiftpm bootstrap on Linux. SE-0047 has a complete implementation now. |
Just got around to taking another look. It looks like the OS X test failed for a different reason than the Linux one:
Which is clearly my fault. I'll look at a fix. |
I switched I have tests mostly done, but is there a good way to build + test just the stdlib? I'm relying on hacked up build scripts to try to validate my work in a reasonable timeframe, which I imagine isn't the right way to do this? |
Thank you! The usual way to test is to run |
We can also run the tests on CI. @swift-ci Please test |
Added some tests to try to hit some edge cases. |
Still not sure what to make of the build failures, any insight @gribozavr? |
Since the time it was last looked at, there are some merge conflicts. @ultramiraculous could you please resolve them? |
51f5c3c
to
c1fbda1
Compare
@swift-ci Please test |
|
||
from SwiftIntTypes import all_integer_types | ||
|
||
word_bits = 4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't look right.
5543333
to
5f4b8f7
Compare
…ailing initializers
@moiseev / @gribozavr Would it make sense to just break this up into 2 or 4 PRs? It got a bit larger than I'd usually prefer to have reviewed after adding the tests, and maybe we could at least get the stable parts of it merged in. |
@ultramiraculous Absolutely, splitting the PR would make things easier! I just have one small request -- while splitting, could you fold the tests for each incremental step into PRs that add or change the APIs? |
What's in this pull request?
Adding failable initializers for builtin numeric types. Added
init?
methods to each numeric type and moved the Float->Int conversions into the FixedPoint template.Resolved bug number: (SR-1491)
Before merging this pull request to apple/swift repository:
Triggering Swift CI
The swift-ci is triggered by writing a comment on this PR addressed to the GitHub user @swift-ci. Different tests will run depending on the specific comment that you use. The currently available comments are:
Smoke Testing
Validation Testing
Lint Testing
Note: Only members of the Apple organization can trigger swift-ci.