Unverified Commit 1cc51296 authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

No longer consider an equation of the form “x(+1) = 0” as defining x to be a constant

Fix this by restricting the detection of constant equations to those where the
variable appears without a lead or lag.

Closes: #83
parent b51f122e
Pipeline #6297 passed with stages
in 4 minutes and 11 seconds
......@@ -5469,10 +5469,13 @@ BinaryOpNode::findConstantEquations(map<VariableNode *, NumConstNode *> &table)
{
if (op_code == BinaryOpcode::equal)
{
if (dynamic_cast<VariableNode *>(arg1) && dynamic_cast<NumConstNode *>(arg2))
table[dynamic_cast<VariableNode *>(arg1)] = dynamic_cast<NumConstNode *>(arg2);
else if (dynamic_cast<VariableNode *>(arg2) && dynamic_cast<NumConstNode *>(arg1))
table[dynamic_cast<VariableNode *>(arg2)] = dynamic_cast<NumConstNode *>(arg1);
// The variable must be contemporaneous (see #83)
if (auto varg1 = dynamic_cast<VariableNode *>(arg1);
varg1 && varg1->lag == 0 && dynamic_cast<NumConstNode *>(arg2))
table[varg1] = dynamic_cast<NumConstNode *>(arg2);
else if (auto varg2 = dynamic_cast<VariableNode *>(arg2);
varg2 && varg2->lag == 0 && dynamic_cast<NumConstNode *>(arg1))
table[varg2] = dynamic_cast<NumConstNode *>(arg1);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment