Skip to content

Commit

Permalink
Add error message for Issue 11717
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuclaw committed Jul 23, 2017
1 parent 56edd1a commit 5ab26bb
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions src/interpret.c
Original file line number Diff line number Diff line change
Expand Up @@ -3154,6 +3154,24 @@ class Interpreter : public Visitor
}
}

bool evalOperand(Expression *e, Expression *ex, Expression *&er)
{
er = interpret(ex, istate);
if (exceptionOrCant(er))
return false;
if (er->isConst() != 1)
{
if (er->op == TOKarrayliteral)
// Until we get it to work, issue a reasonable error message
e->error("cannot interpret array literal expression %s at compile time", e->toChars());
else
e->error("CTFE internal error: non-constant value %s", ex->toChars());
result = CTFEExp::cantexp;
return false;
}
return true;
}

void interpretCommon(BinExp *e, fp_t fp)
{
#if LOG
Expand Down Expand Up @@ -3199,25 +3217,12 @@ class Interpreter : public Visitor
return;
}

Expression *e1 = interpret(e->e1, istate);
if (exceptionOrCant(e1))
Expression *e1;
if (!evalOperand(e, e->e1, e1))
return;
if (e1->isConst() != 1)
{
e->error("CTFE internal error: non-constant value %s", e->e1->toChars());
result = CTFEExp::cantexp;
Expression *e2;
if (!evalOperand(e, e->e2, e2))
return;
}

Expression *e2 = interpret(e->e2, istate);
if (exceptionOrCant(e2))
return;
if (e2->isConst() != 1)
{
e->error("CTFE internal error: non-constant value %s", e->e2->toChars());
result = CTFEExp::cantexp;
return;
}

if (e->op == TOKshr || e->op == TOKshl || e->op == TOKushr)
{
Expand Down

0 comments on commit 5ab26bb

Please sign in to comment.