-
-
Notifications
You must be signed in to change notification settings - Fork 606
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 21868 - conflation of return-ref and return-scope #12665
Conversation
Thanks for your pull request and interest in making D better, @dkorpel! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. 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#12665" |
1ec82e5
to
8a4eb00
Compare
The failing tests say "Exit status: 2" but they don't say "Error:" anywhere. Why are they failing? |
There is a compilation failure in the druntime tests. This probably occurs because your branch is not up-to-date and missing the recent CTFE improvements. The failure should vanish with a rebase (and become impossible after #12667 ) |
c636c72
to
4d84019
Compare
Thank you. Meanwhile, buildkite found: struct Vector(E, Allocator = typeof(theAllocator)) if(isAllocator!Allocator) {
...
E[] _elements;
...
/// Access the ith element. Can throw RangeError.
ref inout(E) opIndex(long i) scope return inout {
if(i < 0 || i >= length)
mixin(throwBoundsException);
return _elements[i.toSizeT];
}
...
foreach(i, ref arg; args)
ptrArgs[i] = (return scope ref const(XLOPER12) a) { return &a; }(arg); Which are legit errors. The latter one doesn't look hard to fix since it's entirely internal, but the former one is a public api. |
4d84019
to
d9f4137
Compare
This PR attempts to do too much. The bug fix should be its own PR, not mixed in with error message improvements. |
True, note that this is still a draft. The idea is to first find the root of the problem and provide a full solution with thorough tests, and then split it up if it's too complex. The current thing blocking progress on this PR is atilaneves/automem#64 |
Attempts to fix 21868 and more. The problem is that escape.d checks for
return
, infersreturn
and suggests to addreturn
without ever checking if it's actually the rightreturn
, e.g. Return-Ref vs. Return-Scope. In the bug report it happens from value->ref with&var
, but it also goes wrong with ref->value with*var
.I added a test for all combinations of ref/non-ref return, and return/scope/ref parameters. I still have to check whether this works with constructors (which return by
ref
but not really or something),out
,ref
in foreach andauto ref
.Note: it still breaks if you assign the parameter to a local variable, but that's a separate issue (20245)
Since this is an accepts-invalid bug, it might break Druntime and Phobos again, we'll see.