mirror of
https://github.com/dlang/dmd.git
synced 2025-04-25 20:50:41 +03:00
substitute inout with const in key and value types
This commit is contained in:
parent
76f066303d
commit
7496f54fc4
2 changed files with 24 additions and 9 deletions
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue