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

+1 vote
ago in Compiler by

The following snippet demonstrate how type hints when put before a macro expression are being lost.
On the first expression, the compiler correctly complains about the wrong type hint while it gets accepted if you wrap the hinted expression on a macro.

$ clj 
Clojure 1.12.3

user=> (import 'java.util.Date)

user=> (.setHours (Date.) ^long (.getHours (Date.)))
Syntax error (UnsupportedOperationException) compiling fn* at (REPL:1:1).
Cannot coerce int to long, use a cast instead

user=> (.setHours (Date.) ^long (-> (.getHours (Date.))))
nil

1 Answer

0 votes
ago by

I believe this is the same general problem as https://clojure.atlassian.net/browse/CLJ-865, which has been long-debated in the core team.

ago by
Given that this received a lot of attention more than 10 years ago and has been untouched since, what are the chances that someone can get work done on changing this behavior? If at this point it's "not worth the effort", should we close the ticket?
ago by
It's not really a question of the work as much as what should be done. Changing the policy of whether macros can/do retain/add to/replace the meta of the original form has a lot of consequences. I would say the door on this is still open - every few years it comes up again and we debate it. Even though we have not yet acted on that, I still think we could, especially if some other need forces the issue.
...