Ensure that unary ops aux vars are never created when there is a lead

The transformation would be incorrect because of the expectation operator.

There was already a safety check, but it was not entirely correct. For example,
if “exp(y)” was appearing before “exp(y(+1))”, the check would not catch the
problem, because it happened after the substitution table had been filled. So
we now do the check before filling that table.
issue#70
Sébastien Villemot 2019-08-19 18:23:56 +02:00
parent 3941278832
commit 9b9c5beb5c
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
1 changed files with 10 additions and 6 deletions

View File

@ -3599,12 +3599,6 @@ UnaryOpNode::substituteUnaryOpNodes(DataTree &static_datatree, diff_table_t &nod
if (it == nodes.end())
return buildSimilarUnaryOpNode(argsubst, datatree);
if (arg->maxLead() > 0)
{
cerr << "Cannot substitute unary operations that contain leads" << endl;
exit(EXIT_FAILURE);
}
string unary_op;
switch (op_code)
{
@ -3682,6 +3676,16 @@ UnaryOpNode::substituteUnaryOpNodes(DataTree &static_datatree, diff_table_t &nod
for (auto rit = it->second.rbegin(); rit != it->second.rend(); ++rit)
if (rit == it->second.rbegin())
{
/* Verify that were not operating on a node with leads, since the
transformation does take into account the expectation operator. We only
need to do this for the first iteration of the loop, because were
going from leads to lags. */
if (rit->second->maxLead() > 0)
{
cerr << "Cannot substitute unary operations that contain leads" << endl;
exit(EXIT_FAILURE);
}
int symb_id;
auto *vn = dynamic_cast<VariableNode *>(argsubst);
if (vn == nullptr)