Skip to content

Commit

Permalink
fix Issue 13221 - [ICE] '0' on line 318 in file 'interpret.c'
Browse files Browse the repository at this point in the history
  • Loading branch information
9rnsr committed Jul 29, 2014
1 parent 77d3f3f commit b16f808
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/interpret.c
Expand Up @@ -713,8 +713,11 @@ void ctfeCompile(FuncDeclaration *fd)
*/
Expression *ctfeInterpret(Expression *e)
{
if (e->type == Type::terror)
if (e->op == TOKerror)
return e;
//assert(e->type->ty != Terror); // FIXME
if (e->type->ty == Terror)
return new ErrorExp();

unsigned olderrors = global.errors;

Expand Down
5 changes: 5 additions & 0 deletions src/mtype.c
Expand Up @@ -4105,12 +4105,17 @@ Type *TypeSArray::semantic(Loc loc, Scope *sc)

dim = dim->optimize(WANTvalue);
dim = dim->ctfeInterpret();
if (dim->op == TOKerror)
goto Lerror;
errors = global.errors;
dinteger_t d1 = dim->toInteger();
if (errors != global.errors)
goto Lerror;

dim = dim->implicitCastTo(sc, tsize_t);
dim = dim->optimize(WANTvalue);
if (dim->op == TOKerror)
goto Lerror;
errors = global.errors;
dinteger_t d2 = dim->toInteger();
if (errors != global.errors)
Expand Down
23 changes: 23 additions & 0 deletions test/fail_compilation/ice13221.d
@@ -0,0 +1,23 @@
/*
TEST_OUTPUT:
---
fail_compilation/ice13221.d(20): Error: variable r cannot be read at compile time
---
*/

struct Tuple(T...)
{
T field;
alias field this;
}

template test(T) {}

void main()
{
foreach (r; 0 .. 0)
{
enum i = r;
test!(Tuple!bool[i]);
}
}

0 comments on commit b16f808

Please sign in to comment.