1
0

fix constant folding

This commit is contained in:
otya128
2016-12-02 21:56:28 +09:00
parent f37089d675
commit a6a205c4c0

View File

@@ -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))