Skip to content

FloatLiteralExpr now is lowered directly into SIL. #23010

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

Merged
merged 1 commit into from
Mar 1, 2019

Conversation

pschuh
Copy link
Contributor

@pschuh pschuh commented Mar 1, 2019

For context, String, Nil, Bool, and Int already behave this way.

Note: Swift can compile against 80 or 64 bit floats as the builtin
literal type. Thus, it was necessary to capture this bit somehow in the
FloatLiteralExpr. This was done as another Type field capturing this
info.

@pschuh pschuh requested a review from slavapestov March 1, 2019 06:03
@slavapestov
Copy link
Contributor

Thank you so much for doing this!

@slavapestov slavapestov self-assigned this Mar 1, 2019
For context, String, Nil, Bool, and Int already behave this way.

Note: Swift can compile against 80 or 64 bit floats as the builtin
literal type. Thus, it was necessary to capture this bit somehow in the
FloatLiteralExpr. This was done as another Type field capturing this
info.
_blackHole(UInt8(-1E309)) // expected-error {{negative literal '-1E309' cannot be converted to 'UInt8'}}
_blackHole(Int64(1E309)) // expected-error {{invalid conversion: '1E309' overflows 'Int64'}}
_blackHole(UInt64(-1E309)) // expected-error {{negative literal '-1E309' cannot be converted to 'UInt64'}}
_blackHole(Int8(1E308)) // expected-error {{invalid conversion: '1E308' overflows 'Int8'}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Great to see these fixed too!

@slavapestov
Copy link
Contributor

@swift-ci Please test

@slavapestov
Copy link
Contributor

@swift-ci Please test source compatibility

@swift-ci
Copy link
Contributor

swift-ci commented Mar 1, 2019

Build failed
Swift Test OS X Platform
Git Sha - f96e8b81985167795600c0790970db297085829e

@swift-ci
Copy link
Contributor

swift-ci commented Mar 1, 2019

Build failed
Swift Test Linux Platform
Git Sha - f96e8b81985167795600c0790970db297085829e

@slavapestov slavapestov merged commit 2813912 into swiftlang:master Mar 1, 2019
@ravikandhadai
Copy link
Contributor

@pschuh I just noticed this. It is nice that false negatives in floating point overflow/underflow detection are fixed by this.

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.

4 participants