aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/nixexpr.cc
diff options
context:
space:
mode:
authorBen Burdette <bburdette@gmail.com>2020-05-21 14:28:45 -0600
committerBen Burdette <bburdette@gmail.com>2020-05-21 14:28:45 -0600
commit0e49de6a2b1a751c744c9e608968e9e32a042db8 (patch)
treeb7bf7a18cea903dcd544e89c47962f0a2dcc6755 /src/libexpr/nixexpr.cc
parent6a420d672ca690ef4235ac7a5833c1789a7d8b10 (diff)
position for stdin, string; (string) for trace; fix tests
Diffstat (limited to 'src/libexpr/nixexpr.cc')
-rw-r--r--src/libexpr/nixexpr.cc17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/libexpr/nixexpr.cc b/src/libexpr/nixexpr.cc
index 91a508305..6ab36dd35 100644
--- a/src/libexpr/nixexpr.cc
+++ b/src/libexpr/nixexpr.cc
@@ -197,7 +197,22 @@ std::ostream & operator << (std::ostream & str, const Pos & pos)
if (!pos)
str << "undefined position";
else
- str << (format(ANSI_BOLD "%1%" ANSI_NORMAL ":%2%:%3%") % (string) pos.file % pos.line % pos.column).str();
+ {
+ auto f = format(ANSI_BOLD "%1%" ANSI_NORMAL ":%2%:%3%");
+ switch (pos.origin) {
+ case foFile:
+ f % (string) pos.file;
+ break;
+ case foStdin:
+ case foString:
+ f % "(string)";
+ break;
+ default:
+ throw Error("unhandled Pos origin!");
+ }
+ str << (f % pos.line % pos.column).str();
+ }
+
return str;
}