Skip to content

Commit

Permalink
fix Issue 12403 - [AA] Associative array get function rejects some …
Browse files Browse the repository at this point in the history
…cases
  • Loading branch information
9rnsr committed Apr 17, 2014
1 parent 6385a7b commit 8cbc11d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/template.c
Expand Up @@ -3533,7 +3533,14 @@ MATCH deduceType(RootObject *o, Scope *sc, Type *tparam, TemplateParameters *par
return;
}

result = deduceType(t->nextOf(), sc, tparam->nextOf(), parameters, dedtypes, wm);
Type *tpn = tparam->nextOf();
if (wm && t->ty == Taarray && tparam->isWild())
{
// Bugzilla 12403: In IFTI, stop inout matching on transitive part of AA types.
tpn = tpn->substWildTo(MODmutable);
}

result = deduceType(t->nextOf(), sc, tpn, parameters, dedtypes, wm);
return;
}

Expand Down
10 changes: 10 additions & 0 deletions test/runnable/testaa3.d
Expand Up @@ -286,6 +286,15 @@ void test12220()
assert(a == 10);
}

/***************************************************/
// 12403

void test12403()
{
const(int)[int] m;
assert(m.get(0, 1) == 1);
}

/***************************************************/

void main()
Expand All @@ -310,4 +319,5 @@ void main()
static assert(testRet());

test12220();
test12403();
}
15 changes: 15 additions & 0 deletions test/runnable/testconst.d
Expand Up @@ -3693,6 +3693,21 @@ void test11768(inout int = 0)
static assert(is(typeof(k1) == typeof(k2))); // fails
}

/************************************/
// 12403

void test12403()
{
void func(K, V)(inout(V[K]) aa)
{
static assert(is(V == const int));
static assert(is(K == int));
}

const(int)[int] m;
func(m);
}

/************************************/

int main()
Expand Down

0 comments on commit 8cbc11d

Please sign in to comment.