Issue 20414 - use of isCopyable on static members of uncopyable struct returns that its copyable
Summary: use of isCopyable on static members of uncopyable struct returns that its cop...
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P3 normal
Assignee: No Owner
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2019-11-22 20:51 UTC by Steven Schveighoffer
Modified: 2022-12-17 10:37 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Steven Schveighoffer 2019-11-22 20:51:28 UTC
e.g.:
import std.traits;

struct X
{
   @disable this(this); // make uncopyable
   pragma(msg, isCopyable!X); // true!
}

pragma(msg, isCopyable!X); // true unless pragma above is commented out

Inspecting whether a struct is copyable inside the struct seems to return that it is, even when it should be disabled. If you remove the inspection inside, then the outer instantiation becomes false.

The use case I have is declaring a static member that works with instances of the struct inside the struct itself.

I initially was thinking this was a Phobos bug, but I think it's an issue with the compiler.