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

extend default in cljs #782

Closed
lilactown opened this issue Jul 25, 2022 · 0 comments
Closed

extend default in cljs #782

lilactown opened this issue Jul 25, 2022 · 0 comments

Comments

@lilactown
Copy link
Contributor

lilactown commented Jul 25, 2022

version

0.3.32 and master

platform

macOS 12.4 / Nodejs v18.3.0

problem

The behavior of (extend-type default ,,,) and (extend-protocol IFoo default ,,,) is different than vanilla CLJS.

repro

There are few different cases.

extend-type:

(defprotocol IFoo (foo [_]))
(extend-type default
 IFoo (foo [_] :default))

(map #(vector (satisfies? IFoo %) (foo %)) [#js {} "" 1 #js [] inc true (js/Object.create nil)])

extend-protocol:

(defprotocol IFoo (foo [_]))
(extend-protocol IFoo
 default (foo [_] :default))

(map #(vector (satisfies? IFoo %) (foo %)) [#js {} "" 1 #js [] inc true (js/Object.create nil)])

expected behavior

The extend-type example should return:

([true :default] [true :default] [true :default] [true :default] [true :default] [true :default] [true :default])

but it will work only for #js {} and does not implement the protocol on any other type.

The extend-protocol example should return the same, but will try and resolve the symbol default and fail.

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

2 participants