-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfdiagnostics QoIBug: Diagnostics Quality of ImplementationBug: Diagnostics Quality of Implementation
Description
Previous ID | SR-897 |
Radar | None |
Original Reporter | elia (JIRA User) |
Type | Improvement |
Additional Detail from JIRA
Votes | 0 |
Component/s | Compiler |
Labels | Improvement, DiagnosticsQoI |
Assignee | None |
Priority | Medium |
md5: d23aee39609546cf931f8061ece93852
Issue Description:
While refactoring a piece of code, I transformed an unconditional `assertionFailure` in an `assert` but I forgot to change the function name. I got this piece of code, which produced a confusing diagnostic:
class A {}
let a: A? = nil
assertionFailure(a != nil, "error”)
Compiling with `swiftc` leads to:
DiagnosticBug.swift:5:20: error: value of type 'A?' can never be nil, comparison isn't allowed
assertionFailure(a != nil, "error")
~ ^
A simple boolean comparison on the other hand produces the diagnostic you’d expect:
let b = true
assertionFailure(b == false, "error”)
DiagnosticBug.swift:9:20: error: cannot convert value of type 'Bool' to expected argument type 'String'
assertionFailure(b == false, "error")
~~^~~~~~~~
Metadata
Metadata
Assignees
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfdiagnostics QoIBug: Diagnostics Quality of ImplementationBug: Diagnostics Quality of Implementation