-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Diagnostics] Fixits for extra arguments in nullary call #16652
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 |
---|---|---|
|
@@ -1666,7 +1666,7 @@ do { | |
f(a: logNoOptional() as ((()) -> Void)) // expected-error {{cannot convert value of type '(()) -> Void' to expected argument type '(() -> Void)?'}} | ||
|
||
func g() {} | ||
g(()) // expected-error {{argument passed to call that takes no arguments}} | ||
g(()) // expected-error {{argument passed to call that takes no arguments}} {{5-7=}} | ||
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. Over here, the error is raised and the test passes. |
||
|
||
func h(_: ()) {} // expected-note {{'h' declared here}} | ||
h() // expected-error {{missing argument for parameter #1 in call}} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,6 +95,16 @@ func parenPatternInArg((a): Int) -> Int { // expected-error {{expected parameter | |
} | ||
parenPatternInArg(0) // expected-error {{argument passed to call that takes no arguments}} | ||
|
||
func nullaryFunctionFixit() {} | ||
nullaryFunctionFixit(()) | ||
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. Here, however, the same error has to be raised, but it doesn't happen. When I run the compiler, it does raise an error. When I run the test, it passes without expecting any error. |
||
|
||
nullaryFunctionFixit(0, 0, "hello") | ||
// expected-error@-1 {{argument passed to call that takes no arguments}} {{22-35=}} | ||
nullaryFunctionFixit(0, 0, "hello" | ||
// expected-error@-1 {{argument passed to call that takes no arguments}} {{22-35=}} {{35-35=)}} | ||
// expected-note@-2 {{to match this opening '('}} | ||
|
||
// expected-error@+1 {{expected ')' in expression list}} | ||
var nullaryClosure: (Int) -> Int = {_ in 0} | ||
_ = nullaryClosure(0) | ||
|
||
|
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.
Sorry, but IMO, we should not remove users code like this. This might be just a mistype of function name.
Removing
()
is implemented in #9583 because of migration need and it probably reflects users intent.