aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/attr-set.hh
diff options
context:
space:
mode:
authorMaximilian Bosch <maximilian@mbosch.me>2021-01-08 22:27:00 +0100
committerMaximilian Bosch <maximilian@mbosch.me>2021-04-13 23:12:38 +0200
commit7c76964daa0d1ca07fd609f5eb28b51afd1246b7 (patch)
tree276736d97532ce6a3feb4920af634c6e61437115 /src/libexpr/attr-set.hh
parent3550a32b25068aa8b1670ef7fd2af2b821f35dc1 (diff)
libexpr: misc improvements for proper error position
When working on some more complex Nix code, there are sometimes rather unhelpful or misleading error messages, especially if coerce-errors are thrown. This patch is a first steps towards improving that. I'm happy to file more changes after that, but I'd like to gather some feedback first. To summarize, this patch does the following things: * Attrsets (a.k.a. `Bindings` in `libexpr`) now have a `Pos`. This is helpful e.g. to identify which attribute-set in `listToAttrs` is invalid. * The `Value`-struct has a new method named `determinePos` which tries to guess the position of a value and falls back to a default if that's not possible. This can be used to provide better messages if a coercion fails. * The new `determinePos`-API is used by `builtins.concatMap` now. With that change, Nix shows the exact position in the error where a wrong value was returned by the lambda. To make sure it's still obvious that `concatMap` is the problem, another stack-frame was added. * The changes described above can be added to every other `primop`, but first I'd like to get some feedback about the overall approach.
Diffstat (limited to 'src/libexpr/attr-set.hh')
-rw-r--r--src/libexpr/attr-set.hh1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/libexpr/attr-set.hh b/src/libexpr/attr-set.hh
index 6d68e5df3..1da8d91df 100644
--- a/src/libexpr/attr-set.hh
+++ b/src/libexpr/attr-set.hh
@@ -35,6 +35,7 @@ class Bindings
{
public:
typedef uint32_t size_t;
+ Pos *pos;
private:
size_t size_, capacity_;