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 13300 - pure function 'std.array.Appender!(T[]).Appender.en… #6811
Conversation
Thanks for your pull request and interest in making D better, @edi33416! 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 fetch digger
dub run digger -- build "stable + phobos#6811" |
a34c2d5
to
0ffc908
Compare
…sureAddable' cannot call impure function 'test.T.__fieldPostBlit'
0ffc908
to
c575e98
Compare
@trikko made the changes such that |
Maybe @jmdavis can give a better review than me |
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 just moves the existing @trusted into more local blocks.
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.
Templates should always infer attributes when whether they're appropriate is affected by the template arguments. And it's almost always better to have @trusted
be as localized as possible, because it makes it clear what is being @trusted
, and it makes it harder to accidentally mark something as @trusted
that wasn't properly vetted.
@jmdavis @wilzbach after taking a closer look at the implementation, I think it has a major flaw. |
Removing auto merge. |
@edi33416 can you please take a look at why druntime's benchmark fails to link (see the build kite failure)? |
The buildkite failure is unrelated as currently druntime's benchmark code gets linked with the currently built Phobos, but somehow still checks out the master version of Phobos. |
OK |
@wilzbach @thewilsonator any thoughts on this?
|
@edi33416 In the case where However, I suspect that the part of the code after that which reallocates the array is wrong, though not in the way you're afraid of. If you take a look at what Given that it's not actually guaranteed that any GC-allocated memory ever has its destructor called, I don't think that this is technically wrong, but it's almost certainly undesirable. Even if proper destruction isn't actually guaranteed, we really want it to be happening if at all possible. Now, I could be misunderstanding something here, since I'm not all that well-versed in the finer details of the GC implementation, but from what I can tell, that's the situation. To give a better response, I'd have to do a lot more digging in the GC. If I were going to ask someone about this, I'd probably ask @schveiguy, since as I understand it, he's pretty familiar with how |
However, there is an interesting thing here. The array capacity (the one the GC knows about and uses) is not set in any of the operations (in only one place it's set, and that's when passing an array that's appendable to Appender constructor). This makes complete sense, since storing the capacity requires knowing all about the druntime lifetime workings, and this is trying to avoid that mechanism since it's definitely slower. But the drawback there is that the GC relies on the capacity to know how many elements of the array are valid for destruction. So there needs to be some work done to make the GC properly call destructors. There are a few ways to do it, but I don't know if that's the way we want to go. The biggest issue I see is that we have to mark the data as appendable and properly store the capacity when the Note that historically, Appender was written before the array runtime added array element destruction. |
…sureAddable' cannot call impure function 'test.T.__fieldPostBlit'
This PR makes
ensureAddable
infer purity. IMHO the entire templated code should infer the attributes from the user provided type.