dep.js: Set up `BAD' correctly.
authorMark Wooding <mdw@distorted.org.uk>
Sat, 30 Jun 2018 21:27:38 +0000 (22:27 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sat, 30 Jun 2018 21:27:38 +0000 (22:27 +0100)
Two bugs, which sort of cancelled each other out.

  * I failed to invoke `new' when I made `BAD', which meant that `BAD'
    actually ended up set to `undefined'.

  * I didn't set `DEP.val' properly if `value' wasn't passed explicitly,
    so, err, it ended up being `undefined', which is then erroneously
    considered to be equivalent to `BAD'.

Fix this silliness.

dep.js

diff --git a/dep.js b/dep.js
index e79b9ad..d5235be 100644 (file)
--- a/dep.js
+++ b/dep.js
@@ -118,7 +118,7 @@ var F_CHANGED = 4;                  // Changed in current phase.
 var F_RECOMPUTING = 8;                 // Currently being recomputed.
 var F_QUEUED = 16;                     // Queued for recomputation.
 
-var BAD = Tag('BAD')                   // Used for the value of `bad' deps.
+var BAD = new Tag('BAD');              // Used for the value of `bad' deps.
 
 var DELAYED = [];                      // Actions delayed by `with_frozen'.
 var PENDING = [];                      // Deps awaiting recomputation.
@@ -178,7 +178,7 @@ function Dep(value, maybefunc) {
     func = value;
     f |= F_QUEUED;
   } else {
-    val = value;
+    val = value === undefined ? BAD : value;
     func = null;
     f |= F_VALUE | F_DEPS;
   }