Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

defrecord: constructor call not recognized in protocol impls #419

Closed
borkdude opened this issue Sep 21, 2020 · 3 comments
Closed

defrecord: constructor call not recognized in protocol impls #419

borkdude opened this issue Sep 21, 2020 · 3 comments

Comments

@borkdude
Copy link
Collaborator

borkdude@MBP2019 ~ $ clj
Clojure 1.10.1
user=> (defprotocol IFoo (foo [this]))
IFoo
user=> (defrecord Foo [x] IFoo (foo [this] (Foo. x)))
user.Foo
user=> ^D
borkdude@MBP2019 ~ $ rlwrap bb
Babashka v0.2.1-SNAPSHOT REPL.
Use :repl/quit or :repl/exit to quit the REPL.
Clojure rocks, Bash reaches.

user=>  (defprotocol IFoo (foo [this]))
{:ns #object[sci.impl.vars.SciNamespace 0x3b233ecd "user"], :methods #{#object[clojure.lang.MultiFn 0x75d2c228 "clojure.lang.MultiFn@108b423c8"]}}
user=>  (defrecord Foo [x] IFoo (foo [this] (Foo. x)))
: Unable to resolve classname: Foo
user=>
@borkdude
Copy link
Collaborator Author

Found the issue: when we resolve Foo. the var is still unbound and fails the check in:

(defn resolve-record-class
  [ctx class-sym]
  (when-let [x (resolve-record-or-protocol-class ctx class-sym)]
    (when (symbol? x) x)))

@borkdude
Copy link
Collaborator Author

I think this depends on a fix for #421.

@borkdude
Copy link
Collaborator Author

Fixed with #421

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant