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

SE-0067 (1/5) - Failable initializers for Fixed->Fixed #2963

Merged
merged 3 commits into from
Jun 22, 2016

Conversation

ultramiraculous
Copy link
Contributor

@ultramiraculous ultramiraculous commented Jun 9, 2016

What's in this pull request?

Breaking out from #2742. Adds init?(exactly:) initializers for integer types from other integer types.

Resolved bug number: (SR-1491)


Before merging this pull request to apple/swift repository:

  • Test pull request on Swift continuous integration.

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

Platform Comment
All supported platforms @swift-ci Please smoke test
All supported platforms @swift-ci Please smoke test and merge
OS X platform @swift-ci Please smoke test OS X platform
Linux platform @swift-ci Please smoke test Linux platform

Validation Testing

Platform Comment
All supported platforms @swift-ci Please test
All supported platforms @swift-ci Please test and merge
OS X platform @swift-ci Please test OS X platform
OS X platform @swift-ci Please benchmark
Linux platform @swift-ci Please test Linux platform

Lint Testing

Language Comment
Python @swift-ci Please Python lint

Note: Only members of the Apple organization can trigger swift-ci.

% conversionFunction = "_convert" + Src + "to" + Self

@_transparent
private func ${conversionFunction}(_ value: ${Src}) -> (value: Builtin.${BuiltinName}, error: Bool) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't use private in the standard library (there are compiler issues), use internal instead.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also wrap to 80 columns (you can break before -> here).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@_transparent functions get inlined at all times, but using a function abstraction here creates work for the optimizer. Also, returning Builtin types from a function is not great either. Could you change this Swift function into a Python function, that just produces the Builtin.*_to_* instruction?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does a template work? (See new commits)

@ultramiraculous ultramiraculous force-pushed the failable-int-int branch 2 times, most recently from da6783b to 9cb6ae2 Compare June 10, 2016 05:47
@gribozavr
Copy link
Contributor

@swift-ci Please test

fixed_fixed_conversion_function,
error_check="Builtin.condfail(result.error)",
**locals()
)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you move the } to a separate line?

@gribozavr
Copy link
Contributor

@ultramiraculous Great work!

I mostly left nitpicky comments.

import gyb



Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind removing extra empty lines?

@ultramiraculous
Copy link
Contributor Author

Addressed the nits!

%
let srcNotWord = v._value
let = value._value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, does this compile?..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hah, jeez you're quick. Turns out it doesn't!

@gribozavr
Copy link
Contributor

@swift-ci Please test

@gribozavr
Copy link
Contributor

@swift-ci Please test and merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants