From 6e9b7fe023943778a903e02cb7169b18d03f2be5 Mon Sep 17 00:00:00 2001 From: Paul Backus Date: Wed, 1 Nov 2023 16:01:01 -0400 Subject: [PATCH] Fix Issue 24215 - isBasicType!Enum should be false --- std/traits.d | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/std/traits.d b/std/traits.d index 2e7a4f6a30b..cc49d76b241 100644 --- a/std/traits.d +++ b/std/traits.d @@ -6480,7 +6480,8 @@ enum bool isScalarType(T) = __traits(isScalar, T) && is(T : real); /** * Detect whether `T` is a basic type (scalar type or void). */ -enum bool isBasicType(T) = isScalarType!T || is(immutable T == immutable void); +enum bool isBasicType(T) = + !is(T == enum) && (isScalarType!T || is(immutable T == immutable void)); /// @safe unittest @@ -6500,6 +6501,13 @@ enum bool isBasicType(T) = isScalarType!T || is(immutable T == immutable void); static assert(isBasicType!(const(dchar))); } +// https://issues.dlang.org/show_bug.cgi?id=24215 +@safe unittest +{ + enum E : int { a } + static assert(!isBasicType!E); +} + /** * Detect whether `T` is a built-in unsigned numeric type. */