[SR-13429] Diagnostic improvement: Provide more contextual information in case of an overflow error #55870
Labels
compiler
The Swift compiler in itself
diagnostics QoI
Bug: Diagnostics Quality of Implementation
improvement
type checker
Area → compiler: Semantic analysis
Additional Detail from JIRA
md5: 0d308c31e3a44c16b6f79d7ad6cf40d5
Issue Description:
If you have code like:
If the user doesn't fully understand how type inference is working, this might be confusing (they might think that the
Int
overload ought to be called). For example, this can lead to potentially surprising behavior aroundUnicode.Scalar
as in SR-13407.It would be helpful in such a situation to point out the overload being used. To characterize the situation properly, here's when I'd expect this contextual information to kick in:
The error is due to overflow.
There are "similar" methods (e.g. other overloads or other initializers) for which the overflow would not happen.
If 2. is too difficult to implement, maybe we can special-case the single-argument initializer situation to address the
Unicode.Scalar
case and handle more complex situations later based on bug reports.The text was updated successfully, but these errors were encountered: