ClojureScript

defprotocol warnings in REPL outside of cljs.user

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Activity

Hide
Jonas Enlund added a comment - - edited

What is the point of this line? It seems to be a primitive kind of resolve-var? If this line is removed (and also the calls to fqn a few lines below) the errors are gone. The effect of removing fqn is that (defprotocol Foo (f [x])) expands to

(cljs.core/defn f
   ([x] (if (cljs.core/and x (. x -foo$Foo$f$arity$1))
          (. x foo$Foo$f$arity$1 x)
          (cljs.core/let [x__2284__auto__ (if (cljs.core/nil? x) nil x)]
                         ((cljs.core/or (cljs.core/aget f (goog.typeOf x__2284__auto__))
                                        (cljs.core/aget f "_")
                                        (throw (cljs.core/missing-protocol "Foo.f" x))) x)))))

instead of

(cljs.core/defn f
   ([x] (if (cljs.core/and x
                           (. x -foo$Foo$f$arity$1))
          (. x foo$Foo$f$arity$1 x)
          (cljs.core/let [x__2284__auto__ (if (cljs.core/nil? x) nil x)]
                         ((cljs.core/or (cljs.core/aget foo.f (goog.typeOf x__2284__auto__))
                                        (cljs.core/aget foo.f "_")
                                        (throw (cljs.core/missing-protocol "Foo.f" x))) x)))))

Note the missing "foo." in (cljs.core/get ...)

Show
Jonas Enlund added a comment - - edited What is the point of this line? It seems to be a primitive kind of resolve-var? If this line is removed (and also the calls to fqn a few lines below) the errors are gone. The effect of removing fqn is that (defprotocol Foo (f [x])) expands to
(cljs.core/defn f
   ([x] (if (cljs.core/and x (. x -foo$Foo$f$arity$1))
          (. x foo$Foo$f$arity$1 x)
          (cljs.core/let [x__2284__auto__ (if (cljs.core/nil? x) nil x)]
                         ((cljs.core/or (cljs.core/aget f (goog.typeOf x__2284__auto__))
                                        (cljs.core/aget f "_")
                                        (throw (cljs.core/missing-protocol "Foo.f" x))) x)))))
instead of
(cljs.core/defn f
   ([x] (if (cljs.core/and x
                           (. x -foo$Foo$f$arity$1))
          (. x foo$Foo$f$arity$1 x)
          (cljs.core/let [x__2284__auto__ (if (cljs.core/nil? x) nil x)]
                         ((cljs.core/or (cljs.core/aget foo.f (goog.typeOf x__2284__auto__))
                                        (cljs.core/aget foo.f "_")
                                        (throw (cljs.core/missing-protocol "Foo.f" x))) x)))))
Note the missing "foo." in (cljs.core/get ...)
Hide
David Nolen added a comment - - edited

Can we please get a patch that doesn't change whitespace, thanks! Also a comment on the patch explaining precisely how this addresses issues at the REPL would be nice.

Show
David Nolen added a comment - - edited Can we please get a patch that doesn't change whitespace, thanks! Also a comment on the patch explaining precisely how this addresses issues at the REPL would be nice.
Hide
David Nolen added a comment - - edited

I believe the issue is really the following:

user>(ns foo)
foo>(fn [] foo.-woz)

Will trigger a resolution warning even tho foo.-woz is an interop/implementation form, not a real way to specify Clojure vars.

We should probably change to resolve-var in analyzer to not warn on cases like this.

Show
David Nolen added a comment - - edited I believe the issue is really the following:
user>(ns foo)
foo>(fn [] foo.-woz)
Will trigger a resolution warning even tho foo.-woz is an interop/implementation form, not a real way to specify Clojure vars. We should probably change to resolve-var in analyzer to not warn on cases like this.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: