Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit 599cac7

Browse files
Fix Issue 20757 - checkaction=context prints characters as integers
1 parent bd67a95 commit 599cac7

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

src/core/internal/dassert.d

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,22 @@ private string miniFormat(V)(const scope ref V v)
9595
}
9696
else static if (__traits(isIntegral, V))
9797
{
98-
enum printfFormat = getPrintfFormat!V;
99-
char[20] val;
100-
const len = sprintf(&val[0], printfFormat, v);
101-
return val.idup[0 .. len];
98+
static if (is(V == char))
99+
{
100+
return ['\'', v, '\''];
101+
}
102+
else static if (is(V == wchar) || is(V == dchar))
103+
{
104+
import core.internal.utf: toUTF8;
105+
return toUTF8(['\'', v, '\'']);
106+
}
107+
else
108+
{
109+
enum printfFormat = getPrintfFormat!V;
110+
char[20] val;
111+
const len = sprintf(&val[0], printfFormat, v);
112+
return val.idup[0 .. len];
113+
}
102114
}
103115
else static if (__traits(isFloating, V))
104116
{

test/exceptions/src/assert_fail.d

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ void testStrings()
6363
// https://issues.dlang.org/show_bug.cgi?id=20322
6464
test("left"w, "right"w, `"left" != "right"`);
6565
test("left"d, "right"d, `"left" != "right"`);
66+
67+
test('A', 'B', "'A' != 'B'");
68+
test(wchar(''), wchar(''), "'❤' != '∑'");
69+
test(dchar(''), dchar(''), "'❤' != '∑'");
6670
}
6771

6872
void testToString()()

0 commit comments

Comments
 (0)