Skip to content

[CSDiagnostics] Offer a fix-it to insert a return type placeholder when returning from a void function #29747

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

Merged
merged 3 commits into from
Feb 11, 2020
Merged

Conversation

theblixguy
Copy link
Collaborator

Currently, when we return from a Void-returning function, an error is emitted:

func voidFunc() {
  return 0 // error: unexpected non-void return value in void function
}

It's likely that the user forgot to add a return type, so add a fix-it to insert a placeholder for the type.

@theblixguy theblixguy requested a review from xedin February 10, 2020 23:15
The function name will be empty in some cases, for example for property setters. In cases where the function name is empty, skip the note and fix-it.
@theblixguy
Copy link
Collaborator Author

@swift-ci please smoke test

@xedin
Copy link
Contributor

xedin commented Feb 11, 2020

@theblixguy Let's hold off from triggering CI for now, it would have to be re-triggered after LLVM changes are done anyway.

@theblixguy
Copy link
Collaborator Author

@swift-ci please smoke test

@theblixguy theblixguy merged commit 2113940 into swiftlang:master Feb 11, 2020
@theblixguy theblixguy deleted the chore/add-non-void-fix-it branch February 11, 2020 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants