Showing with 23 additions and 9 deletions.
  1. +6 −5 src/expression.d
  2. +4 −4 src/mtype.d
  3. +13 −0 test/fail_compilation/ice15317.d
11 changes: 6 additions & 5 deletions src/expression.d
Original file line number Diff line number Diff line change
Expand Up @@ -3813,8 +3813,7 @@ public:
}
if (Type t = s.getType())
{
auto te = new TypeExp(loc, t);
return te.semantic(sc);
return (new TypeExp(loc, t)).semantic(sc);
}
if (TupleDeclaration tup = s.isTupleDeclaration())
{
Expand Down Expand Up @@ -5204,6 +5203,9 @@ public:

override Expression semantic(Scope* sc)
{
if (type.ty == Terror)
return new ErrorExp();

//printf("TypeExp::semantic(%s)\n", type->toChars());
Expression e;
Type t;
Expand Down Expand Up @@ -8101,10 +8103,9 @@ public:
//printf("'%s' is an overload set\n", o->toChars());
return new OverExp(loc, o);
}
Type t = s.getType();
if (t)
if (auto t = s.getType())
{
return new TypeExp(loc, t);
return (new TypeExp(loc, t)).semantic(sc);
}
TupleDeclaration tup = s.isTupleDeclaration();
if (tup)
Expand Down
8 changes: 4 additions & 4 deletions src/mtype.d
Original file line number Diff line number Diff line change
Expand Up @@ -7878,9 +7878,9 @@ public:
ve = ve.semantic(sc);
return ve;
}
if (s.getType())
if (auto t = s.getType())
{
return new TypeExp(e.loc, s.getType());
return (new TypeExp(e.loc, t)).semantic(sc);
}

TemplateMixin tm = s.isTemplateMixin();
Expand Down Expand Up @@ -8732,9 +8732,9 @@ public:
ve = ve.semantic(sc);
return ve;
}
if (s.getType())
if (auto t = s.getType())
{
return new TypeExp(e.loc, s.getType());
return (new TypeExp(e.loc, t)).semantic(sc);
}

TemplateMixin tm = s.isTemplateMixin();
Expand Down
13 changes: 13 additions & 0 deletions test/fail_compilation/ice15317.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// REQUIRED_ARGS: -o-
/*
TEST_OUTPUT:
---
fail_compilation/ice15317.d(11): Error: undefined identifier 'fun'
---
*/

void main()
{
alias f = fun;
auto x1 = &f;
}