<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">I think non-void functions should warn about their return value being unused <b class="">by default</b>, thus eliminating the need to attribute them with @warn_unused_result.<br class=""><br class=""><b class="">Motivation</b><br class=""><br class="">It is a rare case for a result of a function to be unused – and most often it's caused by programmer having too little knowledge of the API. This, in my opinion, is a reasonable area of improvement for the compiler.<div class=""><br class=""></div><div class="">I also noticed that many of stdlib's functions are marked with this attribute, which supports my point of this being the default behavior.<br class=""><br class=""><b class="">Example code<br class=""></b><br class="">The following should be default behavior:<br class=""><br class=""><blockquote type="cite" class=""></blockquote><blockquote type="cite" class=""></blockquote><blockquote type="cite" class="">func square(x: Int) -> Int { return x * x }<br class="">square(2) // warning: result of call to 'square' unused<br class=""></blockquote><br class="">Currently, unless annotated by @warn_unused_result, the compiler will not trigger any warnings.<div class=""><br class=""></div><div class=""><b class="">Supporting old behavior</b><br class=""><div class=""><br class=""></div><div class="">If, sometimes, it is okay to not use the result, an opposite @suppress_unused_result attribute could be used instead.</div><div class=""><br class=""></div><div class=""></div><blockquote type="cite" class=""><div class="">@suppress_unused_result func square(x: Int) -> Int { return x * x }</div><div class="">square(2) // no warning<br class=""></div></blockquote><div class=""><br class=""><b class="">Impact on existing code</b><br class=""><br class="">The existing bare @warn_unused_result attributes will become redundant and can be easily removed by migrator. However, if an existing attribute uses message or mutable_variant argument, it may be left intact, since it provides non-obvious informational value.</div><div class=""><br class=""></div><div class="">Implementing the above proposal would definitely make the code clearer and intentional, without compromising any major use cases.</div><div class=""><br class=""></div><div class="">I would be happy to hear your thought on this.</div><div class=""> <br class=""><br class="">Regards,<br class="">Adrian Kashivskyy<br class=""><br class=""></div></div></div></body></html>