Add L postfix for hex string

This commit is contained in:
Dennis Korpel 2024-01-31 19:48:06 +01:00
parent 068ecd5799
commit 3e9bc4ee17
8 changed files with 48 additions and 12 deletions

View file

@ -243,23 +243,28 @@ void test12950()
void testHexstring()
{
static immutable uint[] x = cast(immutable uint[]) x"FFAADDEE";
static immutable uint[] x = cast(immutable uint[]) x"FFAADDEE"d;
static assert(x[0] == 0xFFAADDEE);
assert(x[0] == 0xFFAADDEE);
static immutable ulong[] y = cast(immutable ulong[]) x"1122334455667788AABBCCDDEEFF0099";
static assert(is(typeof(x""L) == immutable(ulong)[]));
static immutable ulong[] y = x"1122334455667788AABBCCDDEEFF0099"L;
static assert(y[0] == 0x1122334455667788);
static assert(y[1] == 0xAABBCCDDEEFF0099);
assert(y[0] == 0x1122334455667788);
assert(y[1] == 0xAABBCCDDEEFF0099);
immutable long[] c = x"1122334455667788AABBCCDDEEFF0099"L;
assert(c[0] == 0x1122334455667788);
assert(c[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);
// Test printing StringExp with size 8
enum toStr(immutable ulong[] v) = v.stringof;
static assert(toStr!y == `x"88776655443322119900FFEEDDCCBBAA"`);
static assert(toStr!y == `x"88776655443322119900FFEEDDCCBBAA"L`);
// Hex string postfixes
// https://issues.dlang.org/show_bug.cgi?id=24363