"Use of undeclared Var" warning when invoking a protocol method on value with "base" type (e.g., `number`, `string`)
Description
The ClojureScript compiler generates warnings when encountering an invocation of a protocol method when the first parameter is inferred to be of a base/native JavaScript type.
WARNING: Use of undeclared Var type-leak-test-minimal.core/clj-nil at line 6 src/type_leak_test_minimal/core.cljs
WARNING: Use of undeclared Var type-leak-test-minimal.core/number at line 8 src/type_leak_test_minimal/core.cljs
WARNING: Use of undeclared Var type-leak-test-minimal.core/string at line 9 src/type_leak_test_minimal/core.cljs
WARNING: Use of undeclared Var type-leak-test-minimal.core/function at line 13 src/type_leak_test_minimal/core.cljs
WARNING: Use of undeclared Var type-leak-test-minimal.core/object at line 14 src/type_leak_test_minimal/core.cljs
This is true whether or not the protocol is extended to the given type (or to `default`).
Ready-to-run replication case (also showing correct runtime behavior) available on GitHub: sumbach/type-leak-test-minimal.
The ClojureScript compiler generates warnings when encountering an invocation of a protocol method when the first parameter is inferred to be of a base/native JavaScript type.
For example, the following code:
(ns type-leak-test-minimal.core) (defprotocol Foo (foo [x])) (foo nil) (foo js/undefined) (foo 0) (foo "") (foo true) (foo false) (foo identity) (foo (fn [x] x)) (foo #js {}) (foo #js [])
results in the following compiler warnings:
WARNING: Use of undeclared Var type-leak-test-minimal.core/clj-nil at line 6 src/type_leak_test_minimal/core.cljs WARNING: Use of undeclared Var type-leak-test-minimal.core/number at line 8 src/type_leak_test_minimal/core.cljs WARNING: Use of undeclared Var type-leak-test-minimal.core/string at line 9 src/type_leak_test_minimal/core.cljs WARNING: Use of undeclared Var type-leak-test-minimal.core/function at line 13 src/type_leak_test_minimal/core.cljs WARNING: Use of undeclared Var type-leak-test-minimal.core/object at line 14 src/type_leak_test_minimal/core.cljs
This is true whether or not the protocol is extended to the given type (or to `default`).
Ready-to-run replication case (also showing correct runtime behavior) available on GitHub: sumbach/type-leak-test-minimal.