-
-
Notifications
You must be signed in to change notification settings - Fork 610
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
fix Issue 22790 - ref-return-scope is always ref-return, scope, unless return-scope appear in that order #13691
Conversation
|
Thanks for your pull request, @WalterBright! Bugzilla references
Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + dmd#13691" |
e369afa to
7fb96db
Compare
7574ed9 to
44b3eca
Compare
…f-scope appears in that order
44b3eca to
d8d378b
Compare
|
Azure heisenbug: https://issues.dlang.org/show_bug.cgi?id=22791 |
| * value was by ref or not. The new way is `return scope` is set | ||
| * only if the `return` is immediately followed by `scope`, which | ||
| * is done by the parser. | ||
| * Keep the old way to not break pre-dip1000 code. |
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.
How would this break pre-dip1000 code? Lifetime errors only appear with dip1000.
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.
Much of the scope code predates dip1000 and is enabled with or without the switch for it.
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.
That's new to me, can you give a code example of a scope error triggered without dip1000?
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.
see the attached test cases
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.
That makes no sense for two reasons:
- those tests have
REQUIRED_ARGS=-preview=dip1000 - if they didn't, then your PR would break non
-preview=dip1000, which is what you said you didn't do because of this extra condition
|
There's some things missing:
Here's my WIP PR addressing this: #13693 |
I know, but (as usual) doing things incrementally is better than stuffing everything into one PR. I have explained the rationale for this ad nauseum. This piece of the puzzle stands on its own, and merits its own PR. As for the other pieces you mention, a bugzilla issue for each would be worthwhile. |
|
Now the heisenbug shifts to CyberShadow/DAutoTest |
I didn't know you knew, since this your third PR that says it fixes the
If you're aware of the shortcomings of your PRs, why should I need to file new issues after each one? |
So they don't get forgotten. |
It's harder to convey the emphasis in text form, but I meant if you are aware, why should I file them? I'm fine with filing issues and providing test cases, but me re-opening the same issue over and over doesn't feel like effective collaboration. That's why I opened #13693, not because I think everything needs to be done in one PR, but because I want to communicate my plan so we're on the same wavelength. |
|
@dkorpel good points, ok. So what's holding up this PR? |
|
|
All the dip1000 fixes are partial fixes. I shall reiterate why I do things incrementally:
As for breakage, fixing DIP1000 will break code, which is why I put it behind the preview switch. It's the only way forward. |
And I shall reiterate that I know why you do things incrementally and I am not against it, I'm asking you to not close a bugzilla issue by merging a PR with a partial fix for the described issue. Keep the issue open, or narrow the issue down and open issues for the rest.
One thing I will say though is that it can be hard to review dead code that you commit because it's supposed to be used in a later PR. But again: This is not my objection.
You say that without anything backing it up. You didn't add |
It makes it easy to understand and review in the same way that being able to see only a metre out in front of you makes it easy to navigate. It is impossible for reviews to see the forest for the (singular) tree.
That is completely orthogonal to the problem that we can't tell where (the general) this is going. You could for instance open subsequent PRs that are dependant on the previous one so that the reviewers are not short sighted. Also multi commit PRs are a thing, and as long as they are not squashed they are equivalent to a series of PRs. |
See the test cases in this PR.
I've been meaning to speak to you about this. You've been reopening issues when a case not described in the bugzilla shows the fix was incomplete. While this is semantically correct, in practice, it makes life difficult. The bugzilla becomes a meandering discussion with multiple PRs, and trying to figure out what goes with what is confusing and frustrating. What works better is creating a separate bugzilla that references the previously closed one, and supplies the additional failing test case. Then there's a clear chain of successful PRs lining up with what issues they resolve. It's the same idea as keeping PRs small and reviewable.
Because I'm doing things incrementally, for all the reasons I repeatedly explain. If you want to change the bugzilla title, that's ok with me. |
The ref-return-scope triple means "ref return-scope" when |
This was in reference to your preference for incremental PRs, the general this, not this, ref-return-scope. To be blunt, don't expect to get your PRs reviewed if the reviewers can't tell: |
|
My experience is complex PRs don't get reviewed at all. As for this one, the purpose fits in the title rather nicely. |
|
Multi-commit PRs are not a very good substitute. There's no information on whether they pass the test suite or not, making them rather useless in trying to isolate which change caused the problem. |
|
@thewilsonator I don't know your experience, but I've had many where the problem was isolated to a PR that had 800 lines of random code changes spread out over a large number of files. They're a freakin' nightmare to figure out. Even if I wrote them, let alone someone else. Small, incremental, each change passes the test suite, is a method evolved from 40 years of bitter experience. It works, I know it works, I've done it the other way and suffered for it. Have you ever spent an entire week trying to figure out where something is going wrong? |
There's only 2, depending on the return type. It works as designed.
No, there will be only 1. That's the point. |
And it had to CHANGE to get the same semantics. Please read the spec: https://dlang.org/spec/function.html#ref-return-scope-parameters |
Yes, there's two cases of
|
It does not add. It replaces. |
Yes, it had to change because it uses
I did. |
Don't break existing code. |
We go from: if (!returnByRef && isRefReturnScope(fparam.storageClass))To: if (global.params.useDIP1000 != FeatureState.enabled &&
!returnByRef && isRefReturnScope(stc))Notice how there's an extra |
The three bullet points, that's what I'm asking for. |
|
I'm sorry, I don't get your confusion. This PR changes how ref-return-scope behaves, it broke parts of the test suite that tested the previous behavior, and you don't accept that as evidence the behavior changed? |
|
If I post any more tonight, I'm going to say something I'll regret. So I'm going to sign off for today. I recommend you go over what I wrote again. I don't really know how to explain it any differently. |
Which is only a problem of large commits, not PR's containing multiple commits. [1] Binary search in Git But here's a proposal that should work for both of you: Create a draft PR to implement a general solution to the ambiguity and extract standalone patches when applicable. That will allow @dkorpel and others to provide feedback /contribute patches while also enforcing that the individual patches are properly structured (build & pass all tests). |
I'm sorry as well for sounding like a broken record, but:
For code using
Which used
Of course I do, the behavior changed for code using We're talking about the decision to not change code without |
|
It's a new behavior for dip1000. The previous behavior matched the non-dip1000 behavior. |
|
It also alters the name mangling. |
And the suggestion is to make the new dip1000 behavior match the new non-dip1000 behavior instead of introducing a discrepancy. Then you say: but that would break non-dip1000 code! And this somehow repeats every time, I don't know how to get out of this loop. |
Doesn't this mean that after this PR dip1000 code won't link with non-dip1000 code anymore? That doesn't sound desirable. |
|
It means older code will have to recompile all their libraries, even though they aren't using -preview.
People have made (2) very clear to us. |
I don't think we enforce binary compatibility between DMD versions. In any case, since you brought up name mangling, I can finally stop arguing that the // module a.d
int* f(return ref scope int* x)
{
static int* y;
return y;
}// module b.d
import a;
void main()
{
int* x;
f(x);
}The mangle is now inconsistent between dip1000 code and non-dip1000 code, meaning regular (non-preview) code can fail to link against Phobos on functions where that pattern occurs. |
|
@WalterBright please update the tests before merging, now all pipelines are broken. |
|
|
Why was my review dismissed? |
I think we should revert this. |
No description provided.