This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-12-06
Channels
- # adventofcode (54)
- # announcements (3)
- # babashka (34)
- # beginners (38)
- # calva (27)
- # cherry (5)
- # clj-kondo (34)
- # clojure (26)
- # clojure-bay-area (4)
- # clojure-berlin (3)
- # clojure-europe (26)
- # clojure-india (6)
- # clojure-nl (1)
- # clojure-norway (54)
- # clojure-uk (2)
- # conjure (3)
- # cursive (4)
- # data-science (1)
- # emacs (6)
- # events (4)
- # fulcro (2)
- # hugsql (6)
- # hyperfiddle (38)
- # lsp (3)
- # matrix (1)
- # membrane (5)
- # off-topic (27)
- # re-frame (3)
- # releases (1)
- # sci (8)
- # shadow-cljs (34)
- # squint (132)
Afternoon. Does anyone know why a defrecord fails when implementing a protocol from another ns but not when one implementing one from its own ns?
$ nbb -v
nbb v1.2.179
$ nbb -e '(ns storage) (defprotocol IStorage (-store [_ foo])) (ns user [:require [storage]]) (defrecord Storage [] storage/IStorage (-store [_ foo] (prn :foo foo))) (-store (->Storage) :hoo)'
----- Error --------------------------------------
Message: Could not resolve symbol: -store
Location: 1:157
Phase: analysis
----- Stack trace --------------------------------
user - <expr>:1:157
Could not resolve symbol: -store
$ nbb -e '(defprotocol IStorage (-store [_ foo])) (defrecord Storage [] IStorage (-store [_ foo] (prn :foo foo))) (-store (->Storage) :hoo)'
:foo :hoo
Asking about this because I’m trying to run https://github.com/logseq/datascript/blob/51fe8d3fc95056bb82553b3803e5994d194206b4/test/datascript/test/storage.cljs#L11-L13 through nbb’s sci and it also fails to resolve the protocol’s method nameThe issue is not the protocol extension, but your call at the end, this should be:
(storage/-store (->Storage) :hoo)
Ah yep. Thanks. My mistake in trying to make the smallest repro. The original bug I’m seeing isn’t able to load the defprotocol:
bb test [16:34:51]
Running datascript tests...
----- Error --------------------------------------
Message: Could not resolve symbol: -store
Location: /Users/me/code/work/nbb-features/test/libraries/datascript/test/datascript/test/storage.cljs:11:1
Phase: analysis
----- Context ------------------------------------
7: [datascript.core :as d]
8: [datascript.storage :as storage]
9: #_[datascript.test.core :as tdc]))
10:
11: (defrecord Storage [*disk *reads *writes *deletes]
^--- Could not resolve symbol: -store
12: storage/IStorage
13: (-store [_ addr+data-seq]
14: (doseq [[addr data] addr+data-seq]
15: (vswap! *disk assoc addr (pr-str data))
16: (vswap! *writes conj addr)))
Could not resolve symbol: -store
Error while executing task: test
This is in the context of running datascript tests through a custom nbb in nbb-featuresSure. I’ll open up a sci issue with full repro. I thought I’d sanity check ask before doing so but it sounds like this should work