mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[CS] Eagerly bind hole in recordInvalidNode
We know this is where the issue is so we can immediately bind to a hole, ensuring we don't produce unnecessary downstream diagnostics from things we can't infer.
This commit is contained in:
@@ -1126,10 +1126,12 @@ func rdar17170728() {
|
||||
// expected-error@-1 4 {{optional type 'Int?' cannot be used as a boolean; test for '!= nil' instead}}
|
||||
}
|
||||
|
||||
// FIXME: Bad diagnostic, `Bool.Stride` is bogus, we shouldn't be suggesting
|
||||
// `reduce(into:)`, and the actual problem is that Int cannot be used as a boolean
|
||||
// condition.
|
||||
let _ = [i, j, k].reduce(0 as Int?) { // expected-error {{missing argument label 'into:' in call}}
|
||||
// expected-error@-1 {{cannot convert value of type 'Int?' to expected argument type '(inout (Bool, Bool) -> Bool?, Int?) throws -> ()'}}
|
||||
$0 && $1 ? $0 + $1 : ($0 ? $0 : ($1 ? $1 : nil))
|
||||
// expected-error@-1 {{binary operator '+' cannot be applied to two 'Bool' operands}}
|
||||
// expected-error@-1 {{binary operator '+' cannot be applied to operands of type 'Bool.Stride' and 'Bool'}}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -59,6 +59,10 @@ _ = true ? x : 1.2 // expected-error {{result values in '? :' expression have mi
|
||||
_ = (x: true) ? true : false // expected-error {{cannot convert value of type '(x: Bool)' to expected condition type 'Bool'}}
|
||||
_ = (x: 1) ? true : false // expected-error {{cannot convert value of type '(x: Int)' to expected condition type 'Bool'}}
|
||||
|
||||
_ = undefined ? 0 : 1 // expected-error {{cannot find 'undefined' in scope}}
|
||||
_ = [undefined] ? 0 : 1 // expected-error {{cannot find 'undefined' in scope}}
|
||||
// expected-error@-1 {{cannot convert value of type '[Element]' to expected condition type 'Bool'}}
|
||||
|
||||
func resultBool() -> Bool { true }
|
||||
_ = resultBool ? true : false // expected-error {{function 'resultBool' was used as a property; add () to call it}} {{15-15=()}}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user