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

+1 vote
in Errors by

After CLJ-1232 was committed to master, it is possible for the Clojure compiler to throw a NPE if a defn is type hinted with a invalid type. This surfaces in CLJS where the defn macro is re-used by the ClojureScript compiler, but I think it raises the question: "Should a bad type hint result in a compiler exception?"

The offending line can be found here on GitHub: https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L247

5 Answers

0 votes
by

Comment made by: alexmiller

This is basically the same as CLJ-1868, but I think what you are asking here is whether bad type hints should be ignored or throw any exception, right?

(Whereas CLJ-1868 is about which exception/message is thrown)

0 votes
by

Comment made by: halgari

Agreed. I think another possible solution would be to update CLJS to not use the CLJ defn, but I still think that a bad type hint should just be ignored.

0 votes
by

Comment made by: bronsa

I don't agree that we shoud ignore bad type hints.
If the compiler knows that something is wrong, it should tell the user immediately rather than silently ignoring and potentially failing at runtime later

0 votes
by

Comment made by: alexmiller

Description could use some examples

0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJ-1863 (reported by halgari)
...