[SR-9351] Improper error messages when querying the type of an unbound generic #51819
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
compiler
The Swift compiler in itself
diagnostics QoI
Bug: Diagnostics Quality of Implementation
type checker
Area → compiler: Semantic analysis
Environment
This behavior was observed on Swift 4.2.1, on a macOS 10.14.1 platform.
Additional Detail from JIRA
md5: 146288aaba68c3cd83cfd77bcc3a782d
Issue Description:
If you attempt to get the type of an unbound generic type, using Swift's built-in `type(of: )` function, the type solver doesn't produce as meaningful errors as it is able to do in some other contexts.
For instance, if you write:
The compiler produces the following error message, which is arguably less than ideal, as it's quite surprising for any type to not conform to Any:
Similar problems can be observed in other contexts, but with different messages. For instance, the following expression
produces this error, which is better than in the previous example, but still arguably perfectible:
The compiler is able to produce more meaningful messages in more common situations. For instance
produces
The text was updated successfully, but these errors were encountered: