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
Change the warning statement for unused result from expression #12266
Conversation
Thanks! The compiler also has tests for diagnostics like this, using directives like
|
@@ -2814,7 +2814,7 @@ WARNING(expression_unused_result_call,none, | |||
WARNING(expression_unused_result_operator,none, | |||
"result of operator %0 is unused", (DeclName)) | |||
WARNING(expression_unused_result_unknown, none, | |||
"result of call is unused, but produces %0", (Type)) | |||
"result of call to function returning %0 is unused", (Type)) |
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.
Nit: You may not necessarily be calling a function if this is emitted, you may be calling a closure.
I think you can probably delete this and just use expression_unused_result_call
if it's all the same.
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.
@CodaFi I will update it. I think the explicit information will be good and so I will go with your first suggestion.
@huonw thanks for the help. Also, I was curious that how can I run the test locally. Wasn't able to figure out from the documentation. |
@huonw am I missing something? or this PR is ready for acceptance. |
@@ -2814,7 +2814,7 @@ WARNING(expression_unused_result_call,none, | |||
WARNING(expression_unused_result_operator,none, | |||
"result of operator %0 is unused", (DeclName)) | |||
WARNING(expression_unused_result_unknown, none, | |||
"result of call is unused, but produces %0", (Type)) | |||
"result of call to closure returning %0 is unused", (Type)) |
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.
This is not quite what I was pointing out - not everything this diagnoses is a call to a closure, nor is everything it diagnoses a call to a function. So you have two options:
- Conditionalize this diagnostic on whether the called value is a closure or a function.
- Just delete it and use
expression_unused_result_call
instead.
I really recommend #2. This diagnostic seems genuinely superfluous.
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.
@CodaFi Thanks for the context. I thought it is just for closure and I will also not prefer conditionalizing it. I will update it then.
This was addressed by #16059. Thanks! |
Resolves SR-5983.