From 3f94ea1ecba10d663faca0d4bc814057e40dbd70 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Mon, 16 Jan 2017 00:11:54 +0100 Subject: [PATCH] Fix issue 16483 - Prevent an ICE with lambdas as template parameter --- src/expression.d | 8 ++++++++ test/compilable/b16483.d | 12 ++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 test/compilable/b16483.d diff --git a/src/expression.d b/src/expression.d index c2084513d258..70fbbf165bd8 100644 --- a/src/expression.d +++ b/src/expression.d @@ -10102,6 +10102,14 @@ extern (C++) final class CallExp : UnaExp } } } + // If we've got a pointer to a function then deference it + // https://issues.dlang.org/show_bug.cgi?id=16483 + if (e1.type.ty == Tpointer && e1.type.nextOf().ty == Tfunction) + { + Expression e = new PtrExp(loc, e1); + e.type = e1.type.nextOf(); + e1 = e; + } t1 = e1.type; } else if (e1.op == TOKsuper) diff --git a/test/compilable/b16483.d b/test/compilable/b16483.d new file mode 100644 index 000000000000..2bfc2ef1cd1a --- /dev/null +++ b/test/compilable/b16483.d @@ -0,0 +1,12 @@ +struct S +{ + enum a = is(typeof(false.bar!(x => x))); // The lambda compiles + enum b = is(typeof(false.bar!(x => y))); // The lambda doesn't compile +} +auto bar(alias foo)(bool var) +{ + return foo(var); +} +static assert(is(typeof(S.a) == bool)); +static assert(S.a == true); +static assert(S.b == false);