This repository was archived by the owner on Oct 12, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -606,6 +606,10 @@ if (!is(T == enum) && (is(T == interface) || is(T == class))
606
606
// associative array hash. CTFE depends on base types
607
607
size_t hashOf (T)(T aa) if (! is (T == enum ) && __traits(isAssociativeArray, T))
608
608
{
609
+ static if (is (typeof (aa) : V[K], K, V)) {} // Put K & V in scope.
610
+ static if (__traits(compiles, (ref K k, ref V v) nothrow => .hashOf(k) + .hashOf(v)))
611
+ scope (failure) assert (0 ); // Allow compiler to infer nothrow.
612
+
609
613
if (! aa.length) return 0 ;
610
614
size_t h = 0 ;
611
615
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ void main()
6
6
issue18918();
7
7
issue18925();
8
8
issue19005();
9
+ issue19262();
9
10
issue19282();
10
11
testTypeInfoArrayGetHash1();
11
12
testTypeInfoArrayGetHash2();
@@ -86,6 +87,14 @@ void issue19005() @nogc nothrow pure @safe
86
87
auto hash = date.hashOf;
87
88
}
88
89
90
+ // / hashOf associative array should infer nothrow
91
+ void issue19262 () nothrow
92
+ {
93
+ int [int ] aa;
94
+ auto h = hashOf(aa);
95
+ h = hashOf(aa, h);
96
+ }
97
+
89
98
extern (C++ ) class Issue19282CppClass {}
90
99
91
100
// / test that hashOf doesn't crash for non-null C++ objects.
You can’t perform that action at this time.
0 commit comments