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
(cherry picked from commit 1cc512962c
)
5.x
parent
008a0dbb9e
commit
bdbafdc34c
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue