-
Notifications
You must be signed in to change notification settings - Fork 10.6k
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 ImplementationexpressionsFeature: expressionsFeature: expressionsoperatorsFeature: operatorsFeature: operatorsswift 5.9ternary operatorFeature → operators: The ternary operatorFeature → operators: The ternary operatortype checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysistype inferenceFeature: type inferenceFeature: type inference
Description
Description
Here's a session in the repl that demonstrates
Welcome to Apple Swift version 5.8 (swiftlang-5.8.0.124.2 clang-1403.0.22.11.100).
...
3> var a = [1]
a: [Int] = 1 value {
[0] = 1
}
4> a.append(true ? "yes" : "no")
expression failed to parse:
error: repl.swift:4:17: error: result values in '? :' expression have mismatching types 'String' and 'String'
a.append(true ? "yes" : "no")
^~~~~
Obviously the message is nonsense, and the problem is that the conditional expression is fine on its own but has the wrong type for its context.
See the first line of the repl session for version info
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 ImplementationexpressionsFeature: expressionsFeature: expressionsoperatorsFeature: operatorsFeature: operatorsswift 5.9ternary operatorFeature → operators: The ternary operatorFeature → operators: The ternary operatortype checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysistype inferenceFeature: type inferenceFeature: type inference