Help in reviewing druntime PR

Paul Backus snarwin at
Thu Dec 9 15:06:24 UTC 2021

On Thursday, 9 December 2021 at 09:47:10 UTC, Stanislav Blinov 
> ...I mean, it looks like this would have to be ported into 
> Phobos as well, seeing as there's still this weird code 
> duplication for those symbols going on. Though I would rather 
> see those things removed from Phobos and aliased into core, 
> deprecated, then deleted for good.
> But I could add the Phobos change too if there's more eyes 
> there.

Something like this is already in Phobos, under the name 

However, the behavior is not exactly the same. The Phobos version 
recurses into classes, even though they are reference types, 
leading to results like the following:

void example()
     import std.traits;

     class Nested {}
     static struct NotNested
         Nested nested;

     pragma(msg, hasNested!NotNested); // true

I'm not really sure what we should do about this. The Phobos 
behavior seems obviously incorrect to me, but "fixing" it is a 
potentially-breaking change. Maybe the right thing to do is to 
add the fixed version to Phobos as 
`std.traits.hasContextPointers` and mark `hasNested` as 
outdated/unrecommended in the documentation. Thoughts?


More information about the Digitalmars-d mailing list