diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index cf2d3d278f28ff7d8d6837ce8eb5a0dd58aed6c6..5a1f47b55e0d495e76630c20e8fcd45450d34d50 100644
--- a/src/libexpr/primops.cc
+++ b/src/libexpr/primops.cc
@@ -248,7 +248,7 @@ struct CompareValues
     bool operator () (const Value * v1, const Value * v2) const
     {
         if (v1->type != v2->type)
-            throw EvalError("cannot compare values of different types");
+            throw EvalError(format("cannot compare %1% with %2%") % showType(*v1) % showType(*v2));
         switch (v1->type) {
             case tInt:
                 return v1->integer < v2->integer;