-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
Bitwise operation between UInt and Int makes type check exceed time limit #62778
Comments
Each of these similar examples hit the threshold as well: do {
let x: UInt
let y: Int
let _ = (x << x) | (x << x) | (x << x) | (x << x) | y
let _ = (UInt(y) << x) | (UInt(y) << x) | (UInt(y) << x) | y
} |
What could be the fix for This actually seems like a bigger issue not limited to just this example and complexity of the expressions, several people have encountered this as seen in many discussion forums, which lead them to break them into simpler expressions making them write more code, but many other cases, like it also depends on the CPU...(I think 15 seconds is the time limit for Swift for it to analyse)... |
This is a performance issue with the type checker. Performance can mean a lot of things, including time, memory usage, and other data metrics specific to a particular algorithm. Getting an idea of how to solve this at least theoretically requires theoretical and practical knowledge of how expression solving works and its weak spots. You can find a more or less detailed theoretical breakdown of the type checker in the repository’s Keep in mind though, this is by no means a good first issue. |
Hmm, alright, seems quite deep! Thanks for the explanation! |
The root cause of this is reproducible with: let x = 0 + 0 + 0 + 0 + "0"
It's curious to start with (1)
(2, 3)
(4) as shown above; where the compiler lost it's way This bug is old and slows compile times when it happens. |
Thanks for the explanation! @peacedudes |
Description
This code triggers 'the compiler is unable to type-check this expression in reasonable time' error.
Steps to reproduce
Expected behavior
Swift doesn't allow bitwise or between
UInt
andInt
type. With simpler code, the compiler outputs expected error message:Environment
The text was updated successfully, but these errors were encountered: