-
-
Notifications
You must be signed in to change notification settings - Fork 708
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
Help compiler deduce pure
for moveEmplaceImpl
#7670
Conversation
Thanks for your pull request and interest in making D better, @JohanEngelen! 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
|
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 puts no extra requirements on moveEmplaceImpl. moveEmplaceImpl already has to be pure because moveEmplaceImpl is called by moveEmplace which is explicitly marked pure.
But breaks move
which doesn't have this requirement and calls user-defined opAssign
/opPostMove
Fixes issue 21202
I'm shocked to see this stuff is still in |
Yes, but we couldn't remove this as there was one compile-time check that pulled in the world (about 2k of additional templates to druntime) |
Details: #6848 |
@@ -1517,6 +1517,26 @@ pure nothrow @nogc @system unittest | |||
f(move(ncarray)); | |||
} | |||
|
|||
// https://issues.dlang.org/show_bug.cgi?id=21202 | |||
unittest |
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.
Can you please add attributes for the unittest block?
What stops the compiler from inferring the |
What if you put the function body in a |
@JohanEngelen Why is this necessary? The compiler should be able to deduce the purity of that function. |
|
(based on some of the comments, I am no longer convinced this is the correct fix, but the issue still stands) |
@JohanEngelen It is bad practice to force an attribute on a template (especially one that potentially calls user-defined functions). This is more likely a compiler bug. I'm going to close this PR and investigate this to get to the bottom of it. I will close this PR as this is most likely not fixing the root cause. Please reopen if you have anything else to add. |
@RazvanN7 Thanks for looking into fixing the compiler. This workaround is still needed at Weka. |
@JohanEngelen I have looked into it and it looks like a compiler bug: https://issues.dlang.org/show_bug.cgi?id=21850 . |
This fixes https://issues.dlang.org/show_bug.cgi?id=21202 .
This puts no extra requirements on
moveEmplaceImpl
.moveEmplaceImpl
already has to bepure
becausemoveEmplaceImpl
is called bymoveEmplace
which is explicitly markedpure
.