-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Add compiler option for warn on implicit return statement. #2951
Comments
Note: I want to use the named return values because they get included in the ABI that the compiler generates which makes interacting with the contracts from external sources notably easier in some cases and it provides a certain amount of self-documentation. |
Do I understand you correctly that this is about a warning if there is a code path that reaches the end of a function (which returns something) without an explicit return statement? |
Perhaps we could have something like
|
Instead of adding |
@redsquirrel hm, perhaps I'm the only one who really likes them? |
@chriseth I can't say I'm a fan of implicit returns, especially where
readability and security matter. That said, I think it's quite possible to
offer this as a pragma and not super hard to write. I seem to remember
playing around with the "unnamed return variable" when I was doing unused
variable warnings.
…On Fri, Sep 22, 2017 at 8:54 AM chriseth ***@***.***> wrote:
@redsquirrel <https://github.com/redsquirrel> hm, perhaps I'm the only
one who really likes them?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#2951 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAlhYPZtckrkgR8pPPy2x6gLM-9gFl7Yks5sk63zgaJpZM4PgEGS>
.
|
See also: smart contracts 😉 |
I'm okay with However, I will take anything I can get, and if that means the default is current behavior and I have to add a pragma or do |
@MicahZoltu oh of course explicit returns would be the default, otherwise the keyword would be |
This issue has been marked as stale due to inactivity for the last 90 days. |
Hi everyone! This issue has been automatically closed due to inactivity. |
This function does not result in an error or warning because an implicit return statement is added to the end of the function that returns whatever is in the
fruitName
local variable. In a large codebase this can lead to subtle bugs due to the implicit nature of the return statement. I would like the ability to set a compiler flag that allows me to make this a warning. Alternatively, making it always be a compiler warning is fine by me as I think it is not a good practice to have implicit return values.The text was updated successfully, but these errors were encountered: