fix constant folding
This commit is contained in:
@@ -1705,7 +1705,10 @@ class Parser
|
|||||||
if (op.item1.type == NodeType.Constant && op.item2.type == NodeType.Constant)
|
if (op.item1.type == NodeType.Constant && op.item2.type == NodeType.Constant)
|
||||||
{
|
{
|
||||||
double result;
|
double result;
|
||||||
if (constcalc((cast(Constant)op.item1).value, (cast(Constant)op.item2).value, op.operator, result))
|
Constant leftconst = (cast(Constant)op.item1), rightconst = (cast(Constant)op.item2);
|
||||||
|
if (rightconst.value.isNumber && leftconst.value.isNumber)
|
||||||
|
{
|
||||||
|
if (constcalc(leftconst.value, rightconst.value, op.operator, result))
|
||||||
{
|
{
|
||||||
auto l = new Constant(Value(result), lex.location);
|
auto l = new Constant(Value(result), lex.location);
|
||||||
constexpr = true;
|
constexpr = true;
|
||||||
@@ -1715,6 +1718,7 @@ class Parser
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
version(none)
|
version(none)
|
||||||
write(tt, " ");
|
write(tt, " ");
|
||||||
if(order == getOPRank(token.type))
|
if(order == getOPRank(token.type))
|
||||||
|
|||||||
Reference in New Issue
Block a user