digitalmars.D.bugs - [Issue 21635] New: std.bitmanip: bitfields should produce better
- d-bugmail puremagic.com (135/135) Feb 13 2021 https://issues.dlang.org/show_bug.cgi?id=21635
https://issues.dlang.org/show_bug.cgi?id=21635 Issue ID: 21635 Summary: std.bitmanip: bitfields should produce better error messages with wrong parameters Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: phobos Assignee: nobody puremagic.com Reporter: bugzilla bernis-buecher.de struct A { mixin(bitfields!(uint)); } struct B { mixin(bitfields!(uint, "x")); } struct C { mixin(bitfields!(uint, 3, 8)); } struct D { mixin(bitfields!(uint, "x", "x")); } struct E { mixin(bitfields!(float, "x", 32)); } struct F { mixin(bitfields!(ulong, "a", 32, ulong, "b", -32, ulong, "c", 32, ulong, "d", 32)); } struct G { mixin(bitfields!(ulong, "x", 8, ulong, "x", 8)); } The error messages generated by these look like this; they could be better /home/D/Repo/dmd/generated/linux/release/64/../../../../../phobos/std/bitmanip.d(186): Error: tuple index 1 exceeds 1 /home/D/Repo/dmd/generated/linux/release/64/../../../../../phobos/std/bitmanip.d(186): Error: tuple index 2 exceeds 1 /home/D/Repo/dmd/generated/linux/release/64/../../../../../phobos/std/bitmanip.d(187): Error: array index `[2]` is outside array bounds `[0 .. 1]` /home/D/Repo/dmd/generated/linux/release/64/../../../../../phobos/std/bitmanip.d(187): Error: slice `[3..1]` is out of range of `[0..1]` /home/D/Repo/dmd/generated/linux/release/64/../../../../../phobos/std/bitmanip.d(179): Error: template instance `std.bitmanip.createFields!("", 0LU, uint)` error instantiating /home/D/Repo/dmd/generated/linux/release/64/../../../../../phobos/std/bitmanip.d(262): instantiated from here: `createStorageAndFields!uint` test.d(5): instantiated from here: `bitfields!uint` /home/D/Repo/dmd/generated/linux/release/64/../../../../../phobos/std/bitmanip.d(157): Error: slice `[3..2]` is out of range of [0..2] /home/D/Repo/dmd/generated/linux/release/64/../../../../../phobos/std/bitmanip.d(162): Error: template instance `std.bitmanip.createStoreName!(uint, "x")` error instantiating /home/D/Repo/dmd/generated/linux/release/64/../../../../../phobos/std/bitmanip.d(262): instantiated from here: `createStorageAndFields!(uint, "x")` test.d(10): instantiated from here: `bitfields!(uint, "x")` /home/D/Repo/dmd/generated/linux/release/64/../../../../../phobos/std/bitmanip.d(234): Error: array index `[2]` is outside array bounds `[0 .. 2]` /home/D/Repo/dmd/generated/linux/release/64/../../../../../phobos/std/bitmanip.d(234): Error: slice `[3..2]` is out of range of [0..2] /home/D/Repo/dmd/generated/linux/release/64/../../../../../phobos/std/bitmanip.d(163): Error: template instance `std.bitmanip.sizeOfBitField!(uint, "x")` error instantiating /home/D/Repo/dmd/generated/linux/release/64/../../../../../phobos/std/bitmanip.d(262): instantiated from here: `createStorageAndFields!(uint, "x")` test.d(10): instantiated from here: `bitfields!(uint, "x")` /home/D/Repo/dmd/generated/linux/release/64/../../../../../phobos/std/bitmanip.d(186): Error: template instance `createAccessors!("_\x03", uint, 3, 8, 0LU)` does not match template declaration `createAccessors(string store, T, string name, ulong len, ulong offset)` /home/D/Repo/dmd/generated/linux/release/64/../../../../../phobos/std/bitmanip.d(179): Error: template instance `std.bitmanip.createFields!("_\x03", 0LU, uint, 3, 8)` error instantiating /home/D/Repo/dmd/generated/linux/release/64/../../../../../phobos/std/bitmanip.d(262): instantiated from here: `createStorageAndFields!(uint, 3, 8)` test.d(15): instantiated from here: `bitfields!(uint, 3, 8)` /home/D/Repo/dmd/generated/linux/release/64/../../../../../phobos/std/bitmanip.d(234): Error: incompatible types for `("x") + (0)`: `string` and `int` /home/D/Repo/dmd/generated/linux/release/64/../../../../../phobos/std/bitmanip.d(163): Error: template instance `std.bitmanip.sizeOfBitField!(uint, "x", "x")` error instantiating /home/D/Repo/dmd/generated/linux/release/64/../../../../../phobos/std/bitmanip.d(262): instantiated from here: `createStorageAndFields!(uint, "x", "x")` /home/D/Repo/dmd/generated/linux/release/64/../../../../../phobos/std/bitmanip.d(96): Error: no property `min` for type `float`, perhaps `import std.algorithm;` is needed? /home/D/Repo/dmd/generated/linux/release/64/../../../../../phobos/std/bitmanip.d(130): Error: no property `min` for type `float`, perhaps `import std.algorithm;` is needed? /home/D/Repo/dmd/generated/linux/release/64/../../../../../phobos/std/bitmanip.d(186): Error: template instance `std.bitmanip.createAccessors!("_x", float, "x", 32LU, 0LU)` error instantiating /home/D/Repo/dmd/generated/linux/release/64/../../../../../phobos/std/bitmanip.d(179): instantiated from here: `createFields!("_x", 0LU, float, "x", 32)` /home/D/Repo/dmd/generated/linux/release/64/../../../../../phobos/std/bitmanip.d(262): instantiated from here: `createStorageAndFields!(float, "x", 32)` test.d(25): instantiated from here: `bitfields!(float, "x", 32)` /home/D/Repo/dmd/generated/linux/release/64/../../../../../phobos/std/bitmanip.d(93): Error: shift by 96 is outside the range `0..63` /home/D/Repo/dmd/generated/linux/release/64/../../../../../phobos/std/bitmanip.d(94): Error: shift by -33 is outside the range `0..63` /home/D/Repo/dmd/generated/linux/release/64/../../../../../phobos/std/bitmanip.d(106): Error: shift by 96 is outside the range `0..63` /home/D/Repo/dmd/generated/linux/release/64/../../../../../phobos/std/bitmanip.d(186): Error: template instance `std.bitmanip.createAccessors!("_a_b_c_d", ulong, "b", 18446744073709551584LU, 32LU)` error instantiating /home/D/Repo/dmd/generated/linux/release/64/../../../../../phobos/std/bitmanip.d(187): instantiated from here: `createFields!("_a_b_c_d", 32LU, ulong, "b", -32, ulong, "c", 32, ulong, "d", 32)` /home/D/Repo/dmd/generated/linux/release/64/../../../../../phobos/std/bitmanip.d(179): instantiated from here: `createFields!("_a_b_c_d", 0LU, ulong, "a", 32, ulong, "b", -32, ulong, "c", 32, ulong, "d", 32)` /home/D/Repo/dmd/generated/linux/release/64/../../../../../phobos/std/bitmanip.d(262): instantiated from here: `createStorageAndFields!(ulong, "a", 32, ulong, "b", -32, ulong, "c", 32, ulong, "d", 32)` test.d(30): instantiated from here: `bitfields!(ulong, "a", 32, ulong, "b", -32, ulong, "c", 32, ulong, "d", 32)` test.d-mixin-38(42): Error: variable `test.G.x_min` conflicts with variable `test.G.x_min` at test.d-mixin-38(40) test.d-mixin-38(42): Error: variable `test.G.x_max` conflicts with variable `test.G.x_max` at test.d-mixin-38(40) --
Feb 13 2021