Welcome! Please see the About page for a little more info on how this works.

0 votes
in core.typed by

When defining multiple-arity protocol methods with clojure.core.typed/defprotocol, deftypes implementing these methods fail to typecheck with "No matching arities" errors. See attached test case.

2 Answers

0 votes

Comment made by: freakhill

i found a quite similar problem with defrecord. Is there some kind of workaround?

project.clj http://pastebin.com/bn6giuvH
core_typed_bug/core.clj http://pastebin.com/JjfhWLSH
error message http://pastebin.com/djsAicd1

with clojure 1.7.0-beta2 and core.typed 0.2.87

(ns core-typed-bug.core
(:require [ clojure.core.typed :as t ]))

(t/defprotocol P
[a] :- Any
[a b :- Any] :- Any))

(t/ann-record R [])
(defrecord R []
(f [a] 1)
(f [a b] 2))

will give the following arity related errors:

Collected 1 namespaces in 758.831468 msecs
Not checking clojure.core.typed (does not depend on clojure.core.typed)
Start checking core-typed-bug.core
10: Not checking core-typed-bug.core/->R definition
Checked core-typed-bug.core in 923.152062 msecs
Checked 2 namespaces in 1702.704416 msecs
Type Error (core_typed_bug/core.clj:10:1) No matching arities: [R t/Any -> t/Any]
in: (f [a] 1)

Type Error (core_typed_bug/core.clj:10:1) No matching arities: [R -> t/Any] in: (f [a b] 2)

Type Checker: Found 2 errors
Found errors

0 votes
Reference: https://clojure.atlassian.net/browse/CTYP-197 (reported by alex+import)