Fix Issue 21725 - Specifying null as bitfields variable name now fails

This commit is contained in:
Vladimir Panteleev 2021-03-17 11:14:20 +00:00 committed by Nicholas Lindsay Wilson
parent a23fa4ed06
commit e16e0b7b97

View file

@ -297,7 +297,7 @@ string bitfields(T...)()
// would be nice to check for valid variable names too // would be nice to check for valid variable names too
static if (i % 3 == 1) static if (i % 3 == 1)
static assert(is (typeof(ARG) == string), static assert(is (typeof(ARG) : string),
"Variable name expected, found " ~ ARG.stringof); "Variable name expected, found " ~ ARG.stringof);
static if (i % 3 == 2) static if (i % 3 == 2)
@ -637,6 +637,18 @@ unittest
} }
} }
// https://issues.dlang.org/show_bug.cgi?id=21725
@safe unittest
{
struct S
{
mixin(bitfields!(
uint, q{foo}, 4,
uint, null, 4,
));
}
}
/** /**
This string mixin generator allows one to create tagged pointers inside $(D_PARAM struct)s and $(D_PARAM class)es. This string mixin generator allows one to create tagged pointers inside $(D_PARAM struct)s and $(D_PARAM class)es.