Contradictory compiler diagnostics regarding termination and return analysis #73574
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
triage needed
This issue needs more specific labels
Description
Contradictory compiler diagnostics are given in certain cases of infinite loops inside functions.
As seen in the reproduction below there is an error provided for lack of a return, while simultaneously providing a warning/note that the compiler has done enough analysis to see that the ternary expressions will always result in the true branch(which is the literal value true).
The same program that uses the literal true rather than the ternary compiles without error. (Or another simple expression such as 1==1)
Reproduction
Compiler output:
Expected behavior
Better diagnostics and possible documentation of termination analysis limitations.
If Swift is employing partial termination analysis for loops, the compiler should reflect that with appropriate diagnostics.
Environment
swift-driver version: 1.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
Target: arm64-apple-macosx14.0
Additional information
No response
The text was updated successfully, but these errors were encountered: