From 31a86edabc9dbb775ce6eaaa77c28a639a928f6a Mon Sep 17 00:00:00 2001 From: k-hara Date: Tue, 15 Apr 2014 22:50:34 +0900 Subject: [PATCH] fix Issue 12524 - wrong type with inout const arg and inout return --- src/mtype.c | 7 ++++++- test/runnable/testconst.d | 17 +++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/mtype.c b/src/mtype.c index 63296c592a90..f586fd05235e 100644 --- a/src/mtype.c +++ b/src/mtype.c @@ -1935,7 +1935,12 @@ unsigned char Type::deduceWild(Type *t, bool isRef) if (isImmutable()) return MODimmutable; else if (isWildConst()) - return MODwildconst; + { + if (t->isWildConst()) + return MODwild; + else + return MODwildconst; + } else if (isWild()) return MODwild; else if (isConst()) diff --git a/test/runnable/testconst.d b/test/runnable/testconst.d index b0401199e808..fb5c73d15eed 100644 --- a/test/runnable/testconst.d +++ b/test/runnable/testconst.d @@ -2770,6 +2770,23 @@ void validate12089(S)(in S str) void decodeImpl12089(S)(auto ref S str) {} +/************************************/ +// 12524 + +inout(int) dup12524(inout(const(int)) val) +{ + return val; +} + +void test12524(inout(int)) +{ + inout(const(int)) val; + + auto bug = dup12524(val); + + static assert(is(typeof(bug) == inout(int))); +} + /************************************/ // 6941