- 
                Notifications
    
You must be signed in to change notification settings  - Fork 86
 
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
(ns scratch.repro
  {:nextjournal.clerk/no-cache true})
(do
  (declare b)
  (def a 1))
(inc a)Throws
Execution error (ExceptionInfo) at nextjournal.clerk.analyzer/hash-codeblock (analyzer.clj:565).
`->hash` must be `ifn?`from
clerk/src/nextjournal/clerk/analyzer.clj
Lines 562 to 568 in 65988e0
| (defn hash-codeblock [->hash {:as codeblock :keys [hash form id deps vars]}] | |
| (when (and (seq deps) (not (ifn? ->hash))) | |
| (throw (ex-info "`->hash` must be `ifn?`" {:->hash ->hash :codeblock codeblock}))) | |
| (let [hashed-deps (into #{} (map ->hash) deps)] | |
| (sha1-base58 (binding [*print-length* nil] | |
| (pr-str (set/union (conj hashed-deps (if form (remove-type-meta form) hash)) | |
| vars)))))) | 
I find this error pretty confusing, as we should rather check that all dependencies have been hashed at this point, and not that ->hash is just a map. This could allow that certain deps are not hashed and that the nil value lands in the hashed-deps set above.
The error above reproduces only if the node a is at the beginning of the list (hence precedes declare) in the topological sorting of the analyzer graph nodes, this is the not all the time the case, apparently.
This issue is due to the fact that we store the form
(do
  (declare b)
  (def a 1))under the key a in the analysis info map, while it probably should be stored under the block id only.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working