digitalmars.D - need solution for find error : Error: `TypeInfo` cannot be used with
- test123 (6/6) Jul 21 2022 some time a huge project build throw error: "Error: `TypeInfo`
- test123 (3/9) Jul 21 2022 "ldc2/bin/../import/std/array.d(1116): Error: `TypeInfo` cannot
- test123 (26/32) Jul 21 2022 not my first time find this problem. but this time is not make
- Paul Backus (5/6) Jul 22 2022 `bitfields` probably uses an array in CTFE somewhere. Due to
- user1234 (26/38) Jul 22 2022 your bitfield size is not good, which leads to a `to!string` in a
- ryuukk_ (4/4) Jul 22 2022 Alternatively you can grab latest DMD night and use builtin
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). We need solution to improve the error message so people can find where to fix it.
Jul 21 2022
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). We need solution to improve the error message so people can find where to fix it."ldc2/bin/../import/std/array.d(1116): Error: `TypeInfo` cannot be used with -betterC",
Jul 21 2022
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). We need solution to improve the error message so people can find where to fix it.not my first time find this problem. but this time is not make no sense. ```d import std.bitmanip : bitfields; enum UserRole : ubyte { None = 0, } alias UserIdT = ushort; enum BIT_COUNT = 30; enum MAX_COUNT = 2 ^^ BIT_COUNT; struct UserSession { union { ulong uint64; mixin(bitfields!( UserIdT, "user_id", 16, UserRole, "user_role", 2, uint, "login_count", BIT_COUNT, )); } } extern(C) void main(){ } ``` there is no array related code, but throw TypeInfo error
Jul 21 2022
On Friday, 22 July 2022 at 06:16:56 UTC, test123 wrote:there is no array related code, but throw TypeInfo error`bitfields` probably uses an array in CTFE somewhere. Due to limitations of the current compiler, BetterC code is not allowed to use arrays even in code that is only executed at compile time (bug report: https://issues.dlang.org/show_bug.cgi?id=19268).
Jul 22 2022
On Friday, 22 July 2022 at 06:16:56 UTC, test123 wrote:On Friday, 22 July 2022 at 06:06:09 UTC, test123 wrote: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, ```d 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()`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 errorError: array concatenation of expression `cast(const(char)[])s ~ (n > 4294967295LU ? "UL" : "U")` requires the GC which is not available with -betterCwhat'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`.
Jul 22 2022
Alternatively you can grab latest DMD night and use builtin bitfield feature `-preview=bitfields` https://dlang.org/changelog/pending.html#bitfields
Jul 22 2022