diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2018-08-19 11:59:49 +0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2018-08-19 11:59:49 +0200 |
commit | 9b1bdf2db8798c024e6fbe84d4144c04f61d80c7 (patch) | |
tree | fef23a9b3c8ca9a6cf61a4c60e9fdf7c855ea6fc /src | |
parent | d277442df53a01343ba7c1df0bbd2a294058dcba (diff) |
FIx floating point evaluation
Fixes #2361.
Diffstat (limited to 'src')
-rw-r--r-- | src/libexpr/primops.cc | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index 8ace6db4d..6f82c6c40 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -1680,6 +1680,8 @@ static void prim_concatMap(EvalState & state, const Pos & pos, Value * * args, V static void prim_add(EvalState & state, const Pos & pos, Value * * args, Value & v) { + state.forceValue(*args[0], pos); + state.forceValue(*args[1], pos); if (args[0]->type == tFloat || args[1]->type == tFloat) mkFloat(v, state.forceFloat(*args[0], pos) + state.forceFloat(*args[1], pos)); else @@ -1689,6 +1691,8 @@ static void prim_add(EvalState & state, const Pos & pos, Value * * args, Value & static void prim_sub(EvalState & state, const Pos & pos, Value * * args, Value & v) { + state.forceValue(*args[0], pos); + state.forceValue(*args[1], pos); if (args[0]->type == tFloat || args[1]->type == tFloat) mkFloat(v, state.forceFloat(*args[0], pos) - state.forceFloat(*args[1], pos)); else @@ -1698,6 +1702,8 @@ static void prim_sub(EvalState & state, const Pos & pos, Value * * args, Value & static void prim_mul(EvalState & state, const Pos & pos, Value * * args, Value & v) { + state.forceValue(*args[0], pos); + state.forceValue(*args[1], pos); if (args[0]->type == tFloat || args[1]->type == tFloat) mkFloat(v, state.forceFloat(*args[0], pos) * state.forceFloat(*args[1], pos)); else @@ -1707,6 +1713,9 @@ static void prim_mul(EvalState & state, const Pos & pos, Value * * args, Value & static void prim_div(EvalState & state, const Pos & pos, Value * * args, Value & v) { + state.forceValue(*args[0], pos); + state.forceValue(*args[1], pos); + NixFloat f2 = state.forceFloat(*args[1], pos); if (f2 == 0) throw EvalError(format("division by zero, at %1%") % pos); |