Allow casting hexstring to int array (#16079)

This commit is contained in:
Dennis 2024-01-25 10:02:04 +01:00 committed by GitHub
parent e93b26e259
commit ba5402e7ac
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 201 additions and 38 deletions

View file

@ -241,6 +241,23 @@ void test12950()
assert(0b00_00_00_01UL.op12950() == 12951);
}
void testHexstring()
{
static immutable uint[] x = cast(immutable uint[]) x"FFAADDEE";
static assert(x[0] == 0xFFAADDEE);
assert(x[0] == 0xFFAADDEE);
static immutable ulong[] y = cast(immutable ulong[]) x"1122334455667788AABBCCDDEEFF0099";
static assert(y[0] == 0x1122334455667788);
static assert(y[1] == 0xAABBCCDDEEFF0099);
assert(y[0] == 0x1122334455667788);
assert(y[1] == 0xAABBCCDDEEFF0099);
// Test that mangling of StringExp with size 8 is the same as array literal mangling:
void f(immutable ulong[] a)() {}
static assert(f!y.mangleof == f!([0x1122334455667788, 0xAABBCCDDEEFF0099]).mangleof);
}
/***************************************************/
int main()
@ -249,6 +266,7 @@ int main()
test2();
test13907();
test12950();
testHexstring();
printf("Success\n");
return 0;