diff --git a/CHANGELOG.md b/CHANGELOG.md
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,11 @@
 # citeproc changelog
 
+## 0.8.1.3
+
+ * Don't add SubstitutedVal to variables that were empty (#148).
+   This fixes a bug which caused `variable=` tests to succeed
+   in some cases where they should have failed.
+
 ## 0.8.1.2
 
   * Allow containers 0.7 (#143)
diff --git a/citeproc.cabal b/citeproc.cabal
--- a/citeproc.cabal
+++ b/citeproc.cabal
@@ -1,6 +1,6 @@
 cabal-version:       2.2
 name:                citeproc
-version:             0.8.1.2
+version:             0.8.1.3
 synopsis:            Generates citations and bibliography from CSL styles.
 description:         citeproc parses CSL style files and uses them to
                      generate a list of formatted citations and bibliography
diff --git a/src/Citeproc/Eval.hs b/src/Citeproc/Eval.hs
--- a/src/Citeproc/Eval.hs
+++ b/src/Citeproc/Eval.hs
@@ -1643,7 +1643,7 @@
                  Just (NumVal x) -> return $ Literal
                                            $ fromText (T.pack (show x))
                  _ -> return NullOutput
-        deleteSubstitutedVariables [v]
+        unless (isNothing mbv) $ deleteSubstitutedVariables [v]
         if v == "title" && res /= NullOutput
             then do
               modify (\st -> st { stateUsedTitle = True })
diff --git a/stack.yaml b/stack.yaml
--- a/stack.yaml
+++ b/stack.yaml
@@ -2,7 +2,7 @@
   citeproc:
     executable: true
     icu: false
-resolver: lts-19.0
+resolver: lts-23.0
 extra-deps:
 - Diff-1.0.2
 ghc-options:
diff --git a/test/extra/issue_148.txt b/test/extra/issue_148.txt
new file mode 100644
--- /dev/null
+++ b/test/extra/issue_148.txt
@@ -0,0 +1,65 @@
+>>===== MODE =====>>
+citation
+<<===== MODE =====<<
+
+
+
+
+>>===== RESULT =====>>
+Variable not present
+<<===== RESULT =====<<
+
+
+>>===== CSL =====>>
+<?xml version="1.0" encoding="utf-8"?>
+<style xmlns="http://purl.org/net/xbiblio/csl" class="note" version="1.0">
+  <info>
+    <title>Subtitution test</title>
+    <id>http://www.zotero.org/styles/substitution-test</id>
+    <updated>2025-02-02T12:27:40+00:00</updated>
+  </info>
+  <macro name="contributors-note">
+    <names>
+      <substitute>
+        <text variable="editor"/>
+      </substitute>
+    </names>
+  </macro>
+  <citation>
+    <layout>
+      <text macro="contributors-note"/>
+      <choose>
+        <if variable="editor">
+          <text value="Variable present"/>
+        </if>
+        <else-if match="none" variable="editor">
+          <text value="Variable not present"/>
+        </else-if>
+      </choose>
+    </layout>
+  </citation>
+</style>
+<<===== CSL =====<<
+
+
+>>===== CITATION-ITEMS =====>>
+[ [ {"id":"test"} ] ]
+<<===== CITATION-ITEMS =====<<
+
+
+
+>>===== INPUT =====>>
+[
+  {
+    "id": "test",
+    "type": "book",
+    "title": "Title"
+  }
+]
+<<===== INPUT =====<<
+
+
+>>===== VERSION =====>>
+1.0
+<<===== VERSION =====<<
+
