[Issue 21570] New: __traits(isStaticArray, ...) accepts enums with static array as base type
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Jan 21 14:19:29 UTC 2021
https://issues.dlang.org/show_bug.cgi?id=21570
Issue ID: 21570
Summary: __traits(isStaticArray, ...) accepts enums with static
array as base type
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: moonlightsentinel at disroot.org
Example:
-----------------------------------------------------------------
enum EnumArray : int[2] {
a = [ 1, 2 ],
b = [ 3, 4 ]
}
static assert(!__traits(isStaticArray, EnumArray)); // Fails
// Expected equal behaviour of trait and is-expression
static assert(!is(EnumArray == T[n], T, size_t n)); // Passes
-----------------------------------------------------------------
The spec[1] states that a named enum creates a distinct type which is
implicitly convertible to it's base type. So EnumArray is not a static array
and __traits(isStaticArray, EnumArray) should yield `false` as done for the
equivalent is-expression.
[1] https://dlang.org/spec/enum.html#named_enums
--
More information about the Digitalmars-d-bugs
mailing list