On Friday, 22 July 2022 at 06:16:56 UTC, test123 wrote:
> On Friday, 22 July 2022 at 06:06:09 UTC, test123 wrote:
> some time a huge project build throw error: "Error: TypeInfo
cannot be used with -betterC"
and it work before some days ago, there is no array allow but throw this error. no location information (file and line).
[...]
there is no array related code, but throw TypeInfo error
your bitfield size is not good, which leads to a to!string
in a static assert
that uses array under the hood. With a good size,
struct UserSession {
union {
ulong uint64;
mixin(bitfields!(
UserIdT, "user_id", 16,
UserRole, "user_role", 2,
uint, "login_count", BIT_COUNT,
uint, "pad", 16
));
}
}
there's another error in myToString()
> Error: array concatenation of expression cast(const(char)[])s ~ (n > 4294967295LU ? "UL" : "U")
requires the GC which is not available with -betterC
what's unfair is that both problems are caused by static evaluation/CTFE.
That's compiler bugs. The compiler thinks that the code will be used at run-time while it is only statically evaluated, hence there's no betterC restrictions.
For myToString()
, maybe also that pragma(ctfe)
would be required.
I see no solution excepted the one that is to write a simpler, stripped down, version of bitfields
.