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-4984] Integer literal not inferred as unsigned in != comparison #47561
Comments
64-bit targets have the same problem with |
It looks like this is fixed on master, and this is really a library issue, not type checker. |
This is the price we are paying for the heterogeneous comparisons. In the March toolchain the new integer protocols did not exist yet, in May they do. And now there is a generic version of @rudkx, you told me that there was some bug/hack in the compiler to shortcut decision making on operators specifically. In all other cases the typechecker will find all the solutions and rank them, which would choose the (Self, Self) overload in this case. |
Interestingly... Here is the behavior on master now: (swift) UInt() == 0xFFFF_FFFF_FFFF_FFFF
// r0 : Bool = false
(swift) UInt() != 0xFFFF_FFFF_FFFF_FFFF
<REPL Input>:1:11: error: integer literal '18446744073709551615' overflows when stored into 'Int'
UInt() != 0xFFFF_FFFF_FFFF_FFFF
^ So there is hope! |
Testing the solution here: #9909 |
There are various hacks in the type checker, some specific to operators, but generally the issue with default literals is just one example of a bigger choice there, which is having two orthogonal systems for determining what solution is "best", where one of those systems short-circuits trying to find more solutions. |
I don't know if this was (intentionally) solved in a PR but it is no longer occurring in :
I guess I can close the issue? |
It must've been fixed here: #13830 |
@nevil please go ahead and close. |
As reported in #70041, this has regressed. |
Environment
swift-4.0-DEVELOPMENT-SNAPSHOT-2017-05-22-a
Additional Detail from JIRA
md5: 72c3acdcb42f9b52ada14b67693bd331
relates to:
Issue Description:
The below sample code results in build error for 32 bit targets when using swift-4.0-DEVELOPMENT-SNAPSHOT-2017-05-22.
When using "swift-3.1-DEVELOPMENT-SNAPSHOT-2017-03-27" there is no error.
Invocation:
/Library/Developer/Toolchains/swift-4.0-DEVELOPMENT-SNAPSHOT-2017-05-22-a.xctoolchain/usr/bin/swift -frontend -c Overflow.swift -swift-version 3 -target armv7-apple-ios9.0
The text was updated successfully, but these errors were encountered: