Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 24095 - std.bitmanip.bitfields no longer works with bool enum t… #9043

Merged
merged 3 commits into from
Aug 19, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
Loading