diff --git a/compiler/src/dmd/typinf.d b/compiler/src/dmd/typinf.d index 9554eb3214..04e48baa7d 100644 --- a/compiler/src/dmd/typinf.d +++ b/compiler/src/dmd/typinf.d @@ -200,17 +200,18 @@ TypeInfoDeclaration getTypeInfoAssocArrayDeclaration(TypeAArray t, Scope* sc) } /****************************************** -* Find or create a TypeAArray with index and next without any modifiers -* -* Params: -* t = TypeAArray to convert -* Returns: -* t = found type -*/ + * Find or create a TypeAArray with index and next without + * any head modifiers, tail `inout` is replaced with `const` + * + * Params: + * t = TypeAArray to convert + * Returns: + * t = found type + */ Type makeNakedAssociativeArray(TypeAArray t) { - Type tindex = t.index.toBasetype().nakedOf(); - Type tnext = t.next.toBasetype().nakedOf(); + Type tindex = t.index.toBasetype().nakedOf().substWildTo(MODFlags.const_); + Type tnext = t.next.toBasetype().nakedOf().substWildTo(MODFlags.const_); if (tindex == t.index && tnext == t.next) return t; diff --git a/compiler/test/runnable/testaa2.d b/compiler/test/runnable/testaa2.d index ba8ceecc55..e33d47e002 100644 --- a/compiler/test/runnable/testaa2.d +++ b/compiler/test/runnable/testaa2.d @@ -286,6 +286,19 @@ struct PropertyTable10106 CodepointSet10106[string] table; } +/************************************************/ +// strip inout in key and value types +void testinout() +{ + inout(long) func1(inout(long[][int]) aa) + { + return aa[0][0]; + } + long[][int] a = [ 0 : [42] ]; + long b = func1(a); + assert(b == 42); +} + /************************************************/ int main() @@ -295,6 +308,7 @@ int main() test4523(); test3825(); test3825x(); + testinout(); printf("Success\n"); return 0;