Skip to content

Commit

Permalink
Fix Bugzilla Issue 24095 - std.bitmanip.bitfields no longer works wit…
Browse files Browse the repository at this point in the history
…h bool enum types
  • Loading branch information
RubyTheRoobster committed Aug 6, 2024
1 parent 61923d9 commit b795df6
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion std/bitmanip.d
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ private template createAccessors(
enum RightShiftOp = ">>>=";
}

static if (is(T == bool))
static if (is(T : bool))
{
enum createAccessors =
// getter
Expand Down Expand Up @@ -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);
}

0 comments on commit b795df6

Please sign in to comment.