about summary refs log tree commit diff
path: root/src/libexpr
diff options
context:
space:
mode:
Diffstat (limited to 'src/libexpr')
-rw-r--r--src/libexpr/primops.cc5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index 4bf3f5a02707..5ba9830423b0 100644
--- a/src/libexpr/primops.cc
+++ b/src/libexpr/primops.cc
@@ -1635,7 +1635,10 @@ static void prim_match(EvalState & state, const Pos & pos, Value * * args, Value
     const size_t len = match.size() - 1;
     state.mkList(v, len);
     for (size_t i = 0; i < len; ++i) {
-        mkString(*(v.listElems()[i] = state.allocValue()), match[i + 1].str().c_str());
+        if (!match[i+1].matched)
+            mkNull(*(v.listElems()[i] = state.allocValue()));
+        else
+            mkString(*(v.listElems()[i] = state.allocValue()), match[i + 1].str().c_str());
     }
 }