aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/libexpr/eval.cc2
-rw-r--r--tests/lang/eval-okay-getattrpos-undefined.exp1
-rw-r--r--tests/lang/eval-okay-getattrpos-undefined.nix1
3 files changed, 3 insertions, 1 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index 37b977736..854899079 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -628,7 +628,7 @@ void EvalState::mkThunk_(Value & v, Expr * expr)
void EvalState::mkPos(Value & v, Pos * pos)
{
- if (pos) {
+ if (pos && pos->file.set()) {
mkAttrs(v, 3);
mkString(*allocAttr(v, sFile), pos->file);
mkInt(*allocAttr(v, sLine), pos->line);
diff --git a/tests/lang/eval-okay-getattrpos-undefined.exp b/tests/lang/eval-okay-getattrpos-undefined.exp
new file mode 100644
index 000000000..19765bd50
--- /dev/null
+++ b/tests/lang/eval-okay-getattrpos-undefined.exp
@@ -0,0 +1 @@
+null
diff --git a/tests/lang/eval-okay-getattrpos-undefined.nix b/tests/lang/eval-okay-getattrpos-undefined.nix
new file mode 100644
index 000000000..14dd38f77
--- /dev/null
+++ b/tests/lang/eval-okay-getattrpos-undefined.nix
@@ -0,0 +1 @@
+builtins.unsafeGetAttrPos "abort" builtins