You may notice that I have a typo here that I am calling the same variable for iOS versions other than 13. Which will result in crash for less iOS 13 devices.
Probably because there's a path where the function does not call itself: the path where #available returns true. It'd nevertheless be useful to have a warning that says: "All paths through this function will call itself on iOS <13". That's more complicated to detect: paths would need to be checked for all the platform version ranges the function can have. Seems doable though.
If FOO is false, then the second path will be hardcoded into the binary, and the first choice will be deleted, as if it never existed, and the compiler will warn you.
The other kind of checks is made at runtime, and compiler cannot guarantee that the condition won't change
System version checks must be done at runtime, because you can run the same binary on different operating system versions, or even update your linux machine without rebooting it.
I can imagine #available being made a special case in a compiler though, because it would be very weird for the OS version to change in the middle of running the app
cukr’s analysis sounds correct—the DiagnoseInfiniteRecursion pass doesn’t understand that #available(iOS 13, *) is effectively constant, and in fact I don’t think it understands at all that a branch on a constant will always go the same way.