From b795df6df278e9647e4f4967bcd6c694e3a76263 Mon Sep 17 00:00:00 2001 From: RubyTheRoobster Date: Tue, 6 Aug 2024 00:25:38 -0400 Subject: [PATCH 1/3] Fix Bugzilla Issue 24095 - std.bitmanip.bitfields no longer works with bool enum types --- std/bitmanip.d | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/std/bitmanip.d b/std/bitmanip.d index 639b8214c8c..f8d3e09e0fc 100644 --- a/std/bitmanip.d +++ b/std/bitmanip.d @@ -106,7 +106,7 @@ private template createAccessors( enum RightShiftOp = ">>>="; } - static if (is(T == bool)) + static if (is(T : bool)) { enum createAccessors = // getter @@ -4724,3 +4724,24 @@ if (isIntegral!T) foreach (i; 0 .. 63) assert(bitsSet(1UL << i).equal([i])); } + +// Fix https://issues.dlang.org/show_bug.cgi?id=24095 +@safe @nogc pure unittest +{ + enum Bar : bool + { + a, + b, + } + + struct Foo + { + mixin(bitfields!(Bar, "bar", 1, ubyte, "", 7,)); + } + + Foo foo; + foo.bar = Bar.a; + assert(foo.bar == Bar.a); + foo.bar = Bar.b; + assert(foo.bar == Bar.b); +} From 08f79dd844f31038647bf61641793ba7aff922e2 Mon Sep 17 00:00:00 2001 From: RubyTheRoobster Date: Tue, 6 Aug 2024 08:54:29 -0400 Subject: [PATCH 2/3] Fix trailing whitespace --- std/bitmanip.d | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/std/bitmanip.d b/std/bitmanip.d index f8d3e09e0fc..c144f7b644b 100644 --- a/std/bitmanip.d +++ b/std/bitmanip.d @@ -4738,10 +4738,11 @@ if (isIntegral!T) { mixin(bitfields!(Bar, "bar", 1, ubyte, "", 7,)); } - + Foo foo; foo.bar = Bar.a; assert(foo.bar == Bar.a); foo.bar = Bar.b; assert(foo.bar == Bar.b); } + \ No newline at end of file From b69729b0c5c3a4a07af99333db95b39c6aec27d0 Mon Sep 17 00:00:00 2001 From: RubyTheRoobster Date: Wed, 7 Aug 2024 22:38:30 -0400 Subject: [PATCH 3/3] Remove extra space --- std/bitmanip.d | 1 - 1 file changed, 1 deletion(-) diff --git a/std/bitmanip.d b/std/bitmanip.d index c144f7b644b..f8fa3685f7b 100644 --- a/std/bitmanip.d +++ b/std/bitmanip.d @@ -4745,4 +4745,3 @@ if (isIntegral!T) foo.bar = Bar.b; assert(foo.bar == Bar.b); } - \ No newline at end of file