From 8cbc11d4a398e5cd4e4ad487d2e81c607544be5b Mon Sep 17 00:00:00 2001 From: k-hara Date: Thu, 17 Apr 2014 12:48:05 +0900 Subject: [PATCH] fix Issue 12403 - [AA] Associative array `get` function rejects some cases --- src/template.c | 9 ++++++++- test/runnable/testaa3.d | 10 ++++++++++ test/runnable/testconst.d | 15 +++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/template.c b/src/template.c index 9e8a1ebdfaeb..69e031235bc1 100644 --- a/src/template.c +++ b/src/template.c @@ -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; } diff --git a/test/runnable/testaa3.d b/test/runnable/testaa3.d index 9f7f153bb8ba..0ef053f4a6a3 100644 --- a/test/runnable/testaa3.d +++ b/test/runnable/testaa3.d @@ -286,6 +286,15 @@ void test12220() assert(a == 10); } +/***************************************************/ +// 12403 + +void test12403() +{ + const(int)[int] m; + assert(m.get(0, 1) == 1); +} + /***************************************************/ void main() @@ -310,4 +319,5 @@ void main() static assert(testRet()); test12220(); + test12403(); } diff --git a/test/runnable/testconst.d b/test/runnable/testconst.d index fb5c73d15eed..b484b4fce80f 100644 --- a/test/runnable/testconst.d +++ b/test/runnable/testconst.d @@ -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()