Skip to content

Commit

Permalink
Merge pull request #6451 from LemonBoy/b16483
Browse files Browse the repository at this point in the history
Fix issue 16483 - Prevent an ICE with lambdas as template parameter
  • Loading branch information
andralex committed Jan 26, 2017
2 parents ad0d63c + 3f94ea1 commit 254c259
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 @@ -10108,6 +10108,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 254c259

Please sign in to comment.