Skip to content

[SR-8170] IUOs should trap with a distinct error message #50702

@beccadax

Description

@beccadax
Previous ID SR-8170
Radar None
Original Reporter @beccadax
Type Improvement
Status Closed
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler, Standard Library
Labels Improvement, AffectsABI
Assignee @beccadax
Priority Medium

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions