Rewrite object.dup to work with scope and copy constructors#3474
Rewrite object.dup to work with scope and copy constructors#3474dlang-bot merged 3 commits intodlang:masterfrom
object.dup to work with scope and copy constructors#3474Conversation
object.dup to work with scope and copy-constructorsobject.dup to work with scope and copy constructors
|
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 referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. 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 + druntime#3474" |
| static assert( __traits(compiles, () { [].idup!ISthrow; })); | ||
| static assert(!__traits(compiles, () nothrow { [].idup!ISthrow; })); | ||
| static assert( __traits(compiles, () { [].idup!ISunsafe; })); | ||
| static assert(!__traits(compiles, () @safe { [].idup!ISunsafe; })); |
There was a problem hiding this comment.
Remove the useless static assert( __traits(compiles, ...) and move them into a if (false) { ... } if they shouldn't be executed. That ensures proper error messages when the instantiation fails due to some other error.
Also move the instantiation out of the static assert(!__traits(compiles, ...) and only check that the instance cannot be called in a @safe function. Otherwise the test can pass due to other failures.
There was a problem hiding this comment.
Good call, I now just call the valid cases directly and only use the trait to test the function attributes.
If they don't compile because of other reasons, the valid cases should fail first with a decent error message.
|
By the way, I noticed that |
|
I don't know what's happening with the auto-tester... One moment it's reporting "Pending: 8", another moment it's all green. |
"Pending: 8" is correct. The "Details" page is all green, but those results are old. Tests that haven't even started yet are not visible there. You can also find your PR here: https://auto-tester.puremagic.com/pulls.ghtml?projectid=1. There you see that only two results are up to date (bright green). The other eight are not up to date but they passed previously (muted green). |
RazvanN7
left a comment
There was a problem hiding this comment.
Awesome! Thanks for taking care of this.
| } (); | ||
|
|
||
| static if (__traits(hasPostblit, T)) | ||
| _doPostblit(res); |
There was a problem hiding this comment.
This change is problematic because the remaining elements are not initialized to T.init if the postblit/copy constructor throws. The GC will still destroy the entire element.
https://issues.dlang.org/show_bug.cgi?id=21983
Attempted fix: #3483
.dupand.idupused to be built-in properties of arrays along with.sortand.reverse.In 2014 they got implemented as druntime functions, but being 7 years old, they now have the following shortcomings:
scopeinference of the input array fails, making it a blocker for issue 20150 - dip1000 defeated by pureimmutableof e.g.char[].duprelies on a compiler hack.This PR addresses the first two points, the third point depends on a dmd change.
The copy-constructor test are taken from #3139.
The post-blit / copy-constructor logic uses
copyEmplace.