[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
18/64: forceInt: Show position info
From: |
Ludovic Courtès |
Subject: |
18/64: forceInt: Show position info |
Date: |
Mon, 05 Jan 2015 16:38:55 +0000 |
civodul pushed a commit to branch nix
in repository guix.
commit b62d36963c45ccaebb328fceaf0bb40f9c02a14b
Author: Eelco Dolstra <address@hidden>
Date: Fri Apr 4 18:58:15 2014 +0200
forceInt: Show position info
---
src/libexpr/eval.cc | 4 ++--
src/libexpr/eval.hh | 2 +-
src/libexpr/primops.cc | 16 ++++++++--------
3 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index 3a2a849..0be1e73 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -1151,11 +1151,11 @@ void EvalState::strictForceValue(Value & v)
}
-NixInt EvalState::forceInt(Value & v)
+NixInt EvalState::forceInt(Value & v, const Pos & pos)
{
forceValue(v);
if (v.type != tInt)
- throwTypeError("value is %1% while an integer was expected", v);
+ throwTypeError("value is %1% while an integer was expected, at %2%",
v, pos);
return v.integer;
}
diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh
index e69b845..0a424dd 100644
--- a/src/libexpr/eval.hh
+++ b/src/libexpr/eval.hh
@@ -158,7 +158,7 @@ public:
void strictForceValue(Value & v);
/* Force `v', and then verify that it has the expected type. */
- NixInt forceInt(Value & v);
+ NixInt forceInt(Value & v, const Pos & pos);
bool forceBool(Value & v);
inline void forceAttrs(Value & v);
inline void forceList(Value & v);
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index 403edef..b33b76b 100644
--- a/src/libexpr/primops.cc
+++ b/src/libexpr/primops.cc
@@ -954,7 +954,7 @@ static void elemAt(EvalState & state, const Pos & pos,
Value & list, int n, Valu
/* Return the n-1'th element of a list. */
static void prim_elemAt(EvalState & state, const Pos & pos, Value * * args,
Value & v)
{
- elemAt(state, pos, *args[0], state.forceInt(*args[1]), v);
+ elemAt(state, pos, *args[0], state.forceInt(*args[1], pos), v);
}
@@ -1061,27 +1061,27 @@ static void prim_length(EvalState & state, const Pos &
pos, Value * * args, Valu
static void prim_add(EvalState & state, const Pos & pos, Value * * args, Value
& v)
{
- mkInt(v, state.forceInt(*args[0]) + state.forceInt(*args[1]));
+ mkInt(v, state.forceInt(*args[0], pos) + state.forceInt(*args[1], pos));
}
static void prim_sub(EvalState & state, const Pos & pos, Value * * args, Value
& v)
{
- mkInt(v, state.forceInt(*args[0]) - state.forceInt(*args[1]));
+ mkInt(v, state.forceInt(*args[0], pos) - state.forceInt(*args[1], pos));
}
static void prim_mul(EvalState & state, const Pos & pos, Value * * args, Value
& v)
{
- mkInt(v, state.forceInt(*args[0]) * state.forceInt(*args[1]));
+ mkInt(v, state.forceInt(*args[0], pos) * state.forceInt(*args[1], pos));
}
static void prim_div(EvalState & state, const Pos & pos, Value * * args, Value
& v)
{
- NixInt i2 = state.forceInt(*args[1]);
+ NixInt i2 = state.forceInt(*args[1], pos);
if (i2 == 0) throw EvalError(format("division by zero, at %1%") % pos);
- mkInt(v, state.forceInt(*args[0]) / i2);
+ mkInt(v, state.forceInt(*args[0], pos) / i2);
}
@@ -1116,8 +1116,8 @@ static void prim_toString(EvalState & state, const Pos &
pos, Value * * args, Va
non-negative. */
static void prim_substring(EvalState & state, const Pos & pos, Value * * args,
Value & v)
{
- int start = state.forceInt(*args[0]);
- int len = state.forceInt(*args[1]);
+ int start = state.forceInt(*args[0], pos);
+ int len = state.forceInt(*args[1], pos);
PathSet context;
string s = state.coerceToString(*args[2], context);
- 09/64: Tweak error message, (continued)
- 09/64: Tweak error message, Ludovic Courtès, 2015/01/05
- 04/64: Make it work on GNU Make > 3.81 again, Ludovic Courtès, 2015/01/05
- 10/64: Support Illumos, Ludovic Courtès, 2015/01/05
- 11/64: Sync with make-rules repo, Ludovic Courtès, 2015/01/05
- 12/64: Fix compile errors on Illumos, Ludovic Courtès, 2015/01/05
- 13/64: Document that we require a C++11 compiler, Ludovic Courtès, 2015/01/05
- 16/64: Remove unnecessary quotes around file names, Ludovic Courtès, 2015/01/05
- 08/64: Don't set an absolute soname, Ludovic Courtès, 2015/01/05
- 15/64: Include position info in function application, Ludovic Courtès, 2015/01/05
- 14/64: Update release notes, Ludovic Courtès, 2015/01/05
- 18/64: forceInt: Show position info,
Ludovic Courtès <=
- 19/64: forceList: Show position info, Ludovic Courtès, 2015/01/05
- 21/64: forceString: Show position info, Ludovic Courtès, 2015/01/05
- 25/64: Show position info in attribute selection errors, Ludovic Courtès, 2015/01/05
- 29/64: nix-shell --pure: Keep the user's $PAGER, Ludovic Courtès, 2015/01/05
- 27/64: Update release notes, Ludovic Courtès, 2015/01/05
- 26/64: Install systemd units, Ludovic Courtès, 2015/01/05
- 20/64: forceAttrs: Show position info, Ludovic Courtès, 2015/01/05
- 22/64: derivation: Don't require certain function arguments, Ludovic Courtès, 2015/01/05
- 30/64: Update installation instructions, Ludovic Courtès, 2015/01/05
- 23/64: Show position info in string concatenation / addition errors, Ludovic Courtès, 2015/01/05