[SR-8170] IUOs should trap with a distinct error message #50702
Labels
affects ABI
Flag: Affects ABI
compiler
The Swift compiler in itself
improvement
standard library
Area: Standard library umbrella
Additional Detail from JIRA
md5: 2dd2dc20cece34d956473f7aaa2869ac
Issue Description:
When we trap due to a failed force-unwrap, there are two possible causes: either the user wrote a force-unwrap explicitly, or the compiler inserted a force-unwrap for an implicitly unwrapped optional. Explicit force-unwraps are common and easy to notice; IUOs are more rare but much harder to debug (since the places you might unwrap are invisible).
We should trap with a different error messages for explicit and implicit unwraps. This would help users decide whether they should examine the visible `!` characters in their code or audit it for IUOs they didn't account for.
This may affect ABI if we implement it by adding a parameter to the _diagnoseUnexpectedNilOptional function.
The text was updated successfully, but these errors were encountered: