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

Commit aace1c5

Browse files
authored
Merge pull request #2721 from wilzbach/fix-20066
Fix Issue 20066 - Assertion on void[] does not compile with -checkaction=context merged-on-behalf-of: Nicholas Wilson <thewilsonator@users.noreply.github.com>
2 parents 0572437 + dcaf64c commit aace1c5

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/core/internal/dassert.d

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,20 @@ auto miniFormat(V)(V v)
5858
const len = sprintf(&val[0], "%g", v);
5959
return val.idup[0 .. len];
6060
}
61+
// special-handling for void-arrays
62+
else static if (is(V == typeof(null)))
63+
{
64+
return "`null`";
65+
}
6166
else static if (__traits(compiles, { string s = V.init.toString(); }))
6267
{
6368
return v.toString();
6469
}
70+
// special-handling for void-arrays
71+
else static if (is(V == void[]))
72+
{
73+
return "";
74+
}
6575
// anything string-like
6676
else static if (__traits(compiles, V.init ~ ""))
6777
{

test/exceptions/src/assert_fail.d

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,17 @@ void testAttributes() @safe pure @nogc nothrow
119119
assert(a == 0);
120120
}
121121

122+
// https://issues.dlang.org/show_bug.cgi?id=20066
123+
void testVoidArray()()
124+
{
125+
assert([] is null);
126+
assert(null is null);
127+
test([1], null, "[1] != []");
128+
test("s", null, `"s" != ""`);
129+
test(['c'], null, `"c" != ""`);
130+
test!"!="(null, null, "`null` == `null`");
131+
}
132+
122133
void main()
123134
{
124135
testIntegers();
@@ -130,5 +141,6 @@ void main()
130141
testStruct();
131142
testAA();
132143
testAttributes();
144+
testVoidArray();
133145
fprintf(stderr, "success.\n");
134146
}

0 commit comments

Comments
 (0)