ClojureScript

Undeclared Var warnings with static-fns and extend-protocol

Details

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

Description

Odd undeclared Var warnings are emitted if you enable static-fns and use extend-protocol

To repo with script/noderepljs, modify the last line to specify :static-fns true.

Then run the REPL and define a protocol and extend it to nil

cljs.user=> (defprotocol Foo
   (bar [x]))
nil
cljs.user=> (extend-protocol Foo
  nil
  (bar [_] nil))
#object[Function "function (_){
return null;
}"]
cljs.user=> (bar nil)
WARNING: Use of undeclared Var cljs.user/clj-nil at line 1 <cljs repl>
WARNING: Use of undeclared Var cljs.user/clj-nil at line 1 <cljs repl>
nil

If you instead extend to string, and evaluate (bar "abc") you will see:

WARNING: Use of undeclared Var cljs.user/string at line 1 <cljs repl>
WARNING: Use of undeclared Var cljs.user/string at line 1 <cljs repl>

FWIW, the same odd WARNINGs are emitted in self-host mode.

Activity

Hide
Thomas Heller added a comment -

The warning is caused in compiler.cljc [1] that already excludes some tags:

(not ('#{any clj clj-or-nil} tag))

Seems like this issue could be addressed by just adding the "native" type symbols in addition to what is already there.

[1] https://github.com/clojure/clojurescript/blob/9d1b008e6157145ba62e3c849886a2052493a8ac/src/main/clojure/cljs/compiler.cljc#L930

Show
Thomas Heller added a comment - The warning is caused in compiler.cljc [1] that already excludes some tags:
(not ('#{any clj clj-or-nil} tag))
Seems like this issue could be addressed by just adding the "native" type symbols in addition to what is already there. [1] https://github.com/clojure/clojurescript/blob/9d1b008e6157145ba62e3c849886a2052493a8ac/src/main/clojure/cljs/compiler.cljc#L930
Hide
Thomas Heller added a comment -

Probably the same issue here as well:
http://dev.clojure.org/jira/browse/CLJS-1477

Show
Thomas Heller added a comment - Probably the same issue here as well: http://dev.clojure.org/jira/browse/CLJS-1477
Hide
Sam Umbach added a comment -

Mike Fikes David Nolen Can we close this as a duplicate of CLJS-1477?

Show
Sam Umbach added a comment - Mike Fikes David Nolen Can we close this as a duplicate of CLJS-1477?
Hide
Mike Fikes added a comment -

Duplicate of CLJS-1477. No longer reproducible in master both with Node REPL and in bootstrapped environment.

Show
Mike Fikes added a comment - Duplicate of CLJS-1477. No longer reproducible in master both with Node REPL and in bootstrapped environment.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: