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

Commit

Permalink
Merge pull request #3029 from MoonlightSentinel/fix-20731
Browse files Browse the repository at this point in the history
Fix Issue 20731 - checkaction=context fails for structs with 'alias <slice> this'
merged-on-behalf-of: Nicholas Wilson <thewilsonator@users.noreply.github.com>
  • Loading branch information
dlang-bot committed Apr 13, 2020
2 parents 8c84676 + d15e8ec commit ce26f60
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/core/internal/dassert.d
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ overhead small and avoid the use of Phobos.
*/
private string miniFormat(V)(const ref V v)
{
import core.internal.traits: isAggregateType;
import core.stdc.stdio : sprintf;
import core.stdc.string : strlen;
static if (is(V : bool))
Expand Down Expand Up @@ -105,7 +106,8 @@ private string miniFormat(V)(const ref V v)
{
return (cast() v).toString();
}
else static if (is(V : U[], U))
// Static arrays or slices (but not aggregates with `alias this`)
else static if (is(V : U[], U) && !isAggregateType!V)
{
import core.internal.traits: Unqual;
alias E = Unqual!U;
Expand Down
11 changes: 11 additions & 0 deletions test/exceptions/src/assert_fail.d
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,17 @@ void testArray()()
foreach (i; 0 .. 100)
arr ~= i;
test(arr, [0], "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, ...] != [0]");

// Ignore fake arrays
static struct S
{
int[2] arr;
int[] get() { return arr[]; }
alias get this;
}

const a = S([1, 2]);
test(a, S([3, 4]), "S([1, 2]) != S([3, 4])");
}

void testStruct()()
Expand Down

0 comments on commit ce26f60

Please sign in to comment.