Skip to content

Commit

Permalink
Merge pull request #3616 from 9rnsr/fix12841
Browse files Browse the repository at this point in the history
Issue 12841 - ICE on taking function address
  • Loading branch information
WalterBright committed Jun 3, 2014
2 parents 170c2b2 + f1b7537 commit 1e7dda4
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/expression.c
Expand Up @@ -9083,9 +9083,11 @@ Expression *AddrExp::semantic(Scope *sc)
return new ErrorExp;
Dsymbol *s = ti->inst->toAlias();
FuncDeclaration *f = s->isFuncDeclaration();
assert(f);
e1 = new DotVarExp(e1->loc, dti->e1, f);
e1 = e1->semantic(sc);
if (f)
{
e1 = new DotVarExp(e1->loc, dti->e1, f);
e1 = e1->semantic(sc);
}
}
}
else if (e1->op == TOKimport)
Expand All @@ -9099,9 +9101,11 @@ Expression *AddrExp::semantic(Scope *sc)
return new ErrorExp;
Dsymbol *s = ti->inst->toAlias();
FuncDeclaration *f = s->isFuncDeclaration();
assert(f);
e1 = new VarExp(e1->loc, f);
e1 = e1->semantic(sc);
if (f)
{
e1 = new VarExp(e1->loc, f);
e1 = e1->semantic(sc);
}
}
}
e1 = e1->toLvalue(sc, NULL);
Expand Down
25 changes: 25 additions & 0 deletions test/fail_compilation/ice12841.d
@@ -0,0 +1,25 @@
/*
TEST_OUTPUT:
---
fail_compilation/ice12841.d(23): Error: taskPool().amap!"a.result()" is not an lvalue
fail_compilation/ice12841.d(24): Error: amap!"a.result()" is not an lvalue
---
*/

@property TaskPool taskPool() @trusted { return new TaskPool; }

final class TaskPool
{
template amap(functions...)
{
auto amap(Args...)(Args args)
{
}
}
}

void main()
{
auto dg = &(taskPool.amap!"a.result()");
auto fp = &(TaskPool.amap!"a.result()");
}

0 comments on commit 1e7dda4

Please sign in to comment.