Skip to content

Commit

Permalink
Fix issue 16483 - Prevent an ICE with lambdas as template parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
LemonBoy committed Jan 16, 2017
1 parent ece1cf5 commit 3f94ea1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/expression.d
Expand Up @@ -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)
Expand Down
12 changes: 12 additions & 0 deletions 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);

0 comments on commit 3f94ea1

Please sign in to comment.