-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
Conversation
% conversionFunction = "_convert" + Src + "to" + Self | ||
|
||
@_transparent | ||
private func ${conversionFunction}(_ value: ${Src}) -> (value: Builtin.${BuiltinName}, error: Bool) { |
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 don't use private
in the standard library (there are compiler issues), use internal
instead.
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 also wrap to 80 columns (you can break before ->
here).
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.
@_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?
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.
Does a template work? (See new commits)
da6783b
to
9cb6ae2
Compare
@swift-ci Please test |
fixed_fixed_conversion_function, | ||
error_check="Builtin.condfail(result.error)", | ||
**locals() | ||
)} |
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.
Could you move the }
to a separate line?
@ultramiraculous Great work! I mostly left nitpicky comments. |
import gyb | ||
|
||
|
||
|
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.
Would you mind removing extra empty lines?
9cb6ae2
to
92a2a76
Compare
Addressed the nits! |
% | ||
let srcNotWord = v._value | ||
let = value._value |
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.
Oh, does this compile?..
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.
Hah, jeez you're quick. Turns out it doesn't!
@swift-ci Please test |
92a2a76
to
1858b3e
Compare
@swift-ci Please test and merge |
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:
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.