-
Notifications
You must be signed in to change notification settings - Fork 10.5k
SR-1255: Improve diagnostic when one of the parameters marked as autoclosure #5239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -735,8 +735,7 @@ func testNilCoalescePrecedence(cond: Bool, a: Int?, r: CountableClosedRange<Int> | |
|
||
// ?? should have lower precedence than range and arithmetic operators. | ||
let r1 = r ?? (0...42) // ok | ||
let r2 = (r ?? 0)...42 // not ok: expected-error {{binary operator '??' cannot be applied to operands of type 'CountableClosedRange<Int>?' and 'Int'}} | ||
// expected-note @-1 {{overloads for '??' exist with these partially matching parameter lists:}} | ||
let r2 = (r ?? 0)...42 // not ok: expected-error {{cannot convert value of type 'Int' to expected argument type 'CountableClosedRange<Int>'}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't really seem like an improvement, but I'm not sure if it's really that bad if we have the caret in the right place. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is complete output of the diagnostic (caret is at the right place):
|
||
let r3 = r ?? 0...42 // parses as the first one, not the second. | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As with the example in expr/expressions.swift, this seems like a regression.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a user I think it makes more sense to get an error about
"str" as String
producing unexpected type of "String" instead of "NSString" which would much an "NSString?" in that case, because original error is not every helpful to figure out what is actually wrong...Here is the output of the new diagnostic: