-
-
Notifications
You must be signed in to change notification settings - Fork 594
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 23682 - dip1000 problem with return by ref #14869
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#14869" |
I'm not quite sure this fix is right, so I'll look into it further. |
e07beee
to
4879063
Compare
@RazvanN7 it's failing compiling druntime because that gets compiled before the tests/compilable test suite is run. So now I'm doing another reduction job through a thicket of templates. Sigh. |
4879063
to
b59a2f6
Compare
@RazvanN7 I fixed the problem compiling druntime. But the very next thing it does is try to compile Phobos. And then it fails, and I'm borked again by the order in which the test suite is run. Every single check attempts to compile Phobos before running any tests. |
This is failing in std.uni, probably the most template heavy piece of code. I can't make much sense of it. It uses auto so much it's really hard to figure out what types are being used. Anyway, being the pragmatic sort, I'm going to put this fix behind a -preview switch. It's likely to break user code, too, that relied on the old behavior. Hopefully this will get things through the test suite. |
oops pushed the wrong button |
b59a2f6
to
14d7646
Compare
14d7646
to
2335632
Compare
2335632
to
da72089
Compare
da72089
to
050cba1
Compare
You can't run any runnable tests without a runtime library to link. You can't run any compilable LINK tests without a runtime library either (though they if any should be standalone programs). |
It should link with the previous version. |
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.
This is the wrong fix.
Fixing a rejects-valid bug shouldn't break druntime and Phobos.
The function returning by ref
doesn't mean return scope
parameters return a reference to the input variable, that would always be a dangling stack pointer.
The real issue is that assigning a ref
to a non-ref
implicitly dereferences a pointer, but this only manifests in the glue layer, so it's invisible to escape.d.
Without redesigning dmd so the dereferencing of ref
values appears in the front-end AST, here's a possible fix:
#14871
d05029b
to
8d3afb0
Compare
fcec76c
to
a66340e
Compare
A random failure in std.random. I wish somehow we could create repeatable tests. |
a66340e
to
e42c8c0
Compare
Now this new failure on Mac OS:
what's going on here? |
And our old friend, the socket failure, reappears:
|
e42c8c0
to
2b12d6f
Compare
trying again to see if we avoid heisenbugs |
And the heisenbugs go away! Ready to merge. |
@dkorpel ping |
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.
Once again, this fix is overfitted to the single example in the one bugzilla issue, but I can fix this in my PR to solve the issue proper.
|
||
// https://issues.dlang.org/show_bug.cgi?id=23682 | ||
|
||
alias VErr = char*; |
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.
This line is pointless
@@ -1744,7 +1744,27 @@ void escapeByValue(Expression e, EscapeByResults* er, bool live = false, bool re | |||
Parameter p = tf.parameterList[i - j]; | |||
const stc = tf.parameterStorageClass(null, p); | |||
ScopeRef psr = buildScopeRef(stc); | |||
if (psr == ScopeRef.ReturnScope || psr == ScopeRef.Ref_ReturnScope) |
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.
Ref_ReturnScope
should not be treated different to ReturnScope
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.
they are different because a ReturnScope can be returned as a Ref
The trouble is a ref return from a struct constructor is different from a regular ref return. It's an inconsistency in the language, but I don't think there's much we can do about it. |
No description provided.