technomancy / slamhound

Slamhound rips your namespace form apart and reconstructs it.
Other
473 stars 38 forks source link

Play nice with core.typed / :refer type aliases #70

Closed seancorfield closed 10 years ago

seancorfield commented 10 years ago

We refer certain type aliases in from core.typed:

[clojure.core.typed :refer [ann def-alias for> loop> Map Option Vec]]

Then we have create a type alias:

(def-alias SBWResult (HMap :mandatory {:result String
                                       :errors (Vec String)}))

Slamhound barfs on the use of Vec:

Failed to reconstruct: #<File src/worldsingles/payment/sbw.clj>
Internal Error (slamhound.sandbox__1222__auto__:<NO LINE>) Cannot resolve type: Vec
Hint: Is Vec in scope?
Hint: Has Vec's annotation been found via check-ns, cf or typed-deps?

Note, as with the previous core.typed / Slamhound issue, it tries to run core.typed after failing to reconstruct the namespace (the Internal Error is from core.typed). Slamhound doesn't explain why it can't reconstruct the namespace.

guns commented 10 years ago

Both of these issues appear to stem from the fact that in an effort to provide user friendly messages, core.typed macros catch the Exceptions that Slamhound uses to identify unknown references.

ATM I think we will probably need to add explicit support for core.typed (since it is a contrib library). In the long term I hope to move Slamhound to use the new static analyzers; if this is possible this kind of workaround won't be necessary.

Thanks a ton!

guns commented 10 years ago

I think this addresses both core.typed issues. Thanks again for the feedback!

seancorfield commented 10 years ago

This seems to have solved my problems - thank you for such a swift fix!