Skip to content

Commit c660dd7

Browse files
authored
Fix __traits(isCopyable) fails on static array of non-copyable struct (dlang#22660)
Fixes dlang#22658.
1 parent a118d9c commit c660dd7

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

compiler/src/dmd/traits.d

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,8 @@ Expression semanticTraits(TraitsExp e, Scope* sc)
588588
return ErrorExp.get();
589589
}
590590

591-
t = t.toBasetype(); // get the base in case `t` is an `enum`
591+
// get enum base or static array element type
592+
t = t.baseElemOf();
592593

593594
if (auto ts = t.isTypeStruct())
594595
{

compiler/test/compilable/traits.d

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ class C1 {}
169169
static assert( __traits(isCopyable, S1));
170170
static assert( __traits(isCopyable, S2));
171171
static assert(!__traits(isCopyable, S3));
172+
static assert(!__traits(isCopyable, S3[1]));
172173
static assert(!__traits(isCopyable, S4));
173174
static assert(__traits(isCopyable, C1));
174175
static assert(__traits(isCopyable, int));

0 commit comments

Comments
 (0)