-
-
Notifications
You must be signed in to change notification settings - Fork 609
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
get started on scope diagnostics #5903
Conversation
|
Blocked by dlang/phobos#4549 |
| return; | ||
| } | ||
| } | ||
| error(e.loc, "scope variable %s may not be returned", v); |
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.
Small language nitpick, "may" sounds a bit too optional for me. Shouldn't we use sth like "can't"?
(Disclaimer: I am not a native speaker.)
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.
"may not" does not mean "optional". I also prefer to avoid contractions in code because grepping for them is a pain because of the quote.
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.
"may" can be used to indicate both optionality or regulation, but when negated it is always as strong as "must not", so it sounds good to me.
In the long term we should probably adopt RFC 2119 for the specification and compiler messages, but that would be a huge effort.
217db64 to
a3dc004
Compare
|
Blocked by dlang/phobos#4556 |
|
In general I support this change, but as noted in the Phobos PR, this could potentially affect a lot of code that uses functions that take scope delegates. Is it possible to mitigate this by making something like |
|
In the future there will be |
|
Auto-merge toggled on |
Great, that's exactly what I want. I just didn't know that we would be able to use both at the same time. |
|
This PR caused a regression. |
|
@MartinNowak shall we undo this? |
|
It is fixed by #5972 |
But we can't drag that into the release now that the beta is almost done.
It's non-trivial (but doable) to undo after 3 month and lots of follow-up refactorings. |
Sure, but I suggested merging it in a month ago for just that reason.
Not merging things creates another set of problems. For example, there's not a single review yet of the return scope PR. Nobody wants to review large PRs. And at least with this regression, the culprit is small rather than large.
A practical alternative is to disable the error unless
Thank you. |
Well you still submitted them in a different order :).
Hence feature branches, early review, no risk in master.
The one we see, but not necessarily the effect of it. The phobos bug was triggered by some meta code in vibe.d or so, which would affect plenty of users... |
See #6183 for why this isn't the correct approach. I'll make a pass through the project tester, trying to find any other code that runs into problems with this. |
|
Is |
Acceptance tests > reviews. Focus on featuring clear practical examples of new feature as part of PR unittests and there will be much less reluctance to merge because it becomes obvious what that huge PR actually does. It would help a lot if each time I was sending you e-mail with snippets regarding DIP1000, you would have added them as unit-tests instead of explanations via mail. |
No, it's not, not even sure I can find docs for that. |
|
Thanks, dmd doesn't seem to apply scope to in parameters atm. This might actually be an oversight of this PR. const(int)* test(in int* p)
{
return p;
} |
No description provided.