aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Burdette <bburdette@gmail.com>2020-05-11 17:34:57 -0600
committerBen Burdette <bburdette@gmail.com>2020-05-11 17:34:57 -0600
commit7c3138844ca9ab92e2f231a7d17d7aee420ae76e (patch)
tree63d316a1b18bb0a77267d2490811a8eee81adc0c
parent631642c5b40032a087b8e2e131b2ebcac00913d3 (diff)
more pos reporting
-rw-r--r--src/libexpr/nixexpr.cc8
-rw-r--r--src/libexpr/parser.y8
2 files changed, 11 insertions, 5 deletions
diff --git a/src/libexpr/nixexpr.cc b/src/libexpr/nixexpr.cc
index a9955f6df..91a508305 100644
--- a/src/libexpr/nixexpr.cc
+++ b/src/libexpr/nixexpr.cc
@@ -267,8 +267,12 @@ void ExprVar::bindVars(const StaticEnv & env)
/* Otherwise, the variable must be obtained from the nearest
enclosing `with'. If there is no `with', then we can issue an
"undefined variable" error now. */
- if (withLevel == -1) throw UndefinedVarError("undefined variable '%1%' at %2%", name, pos);
-
+ if (withLevel == -1)
+ throw UndefinedVarError(
+ ErrorInfo {
+ .hint = hintfmt("undefined variable '%1%'", name),
+ .nixCode = NixCode { .errPos = pos }
+ });
fromWith = true;
this->level = withLevel;
}
diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y
index 6d50d74ba..3ae7bbafd 100644
--- a/src/libexpr/parser.y
+++ b/src/libexpr/parser.y
@@ -31,7 +31,7 @@ namespace nix {
Expr * result;
Path basePath;
Symbol path;
- string error;
+ ErrorInfo error;
Symbol sLetBody;
ParseData(EvalState & state)
: state(state)
@@ -261,8 +261,10 @@ static inline Pos makeCurPos(const YYLTYPE & loc, ParseData * data)
void yyerror(YYLTYPE * loc, yyscan_t scanner, ParseData * data, const char * error)
{
- data->error = (format("%1%, at %2%")
- % error % makeCurPos(*loc, data)).str();
+ data->error = ErrorInfo {
+ .hint = hintfmt(error),
+ .nixCode = NixCode { .errPos = makeCurPos(*loc, data) }
+ };
}