Use qualified class names for return type hints of standard Clojure functions


tools.analyzer (used by the Clojure lint tool Eastwood) crashes when encountering such a simple-named return type hint. So currently, I cannot lint parts of my project because there's code that calls `clojure.core/format`.

Cause: return type class names are not fully qualified in clojure.core.

Solution: The attached patch converts all function return type hints to spell out the class name fully qualified.

Patch: 0001-Use-fully-qualified-class-names-for-return-type-hint.patch




Alex Miller
December 14, 2015, 10:52 PM

Closed per Nicola.

Alex Miller
December 14, 2015, 9:21 PM

Updated to simplify this ticket now that CLJ-1232 is closed.

As written, the ticket looks like it is a problem with tools.analyzer rather than with Clojure. Is this ticket still accurate wrt latest Clojure and tools.analyzer?

If so, please give a reproducible example in the description.

Tassilo Horn
August 28, 2014, 8:16 PM

Nicola, you are correct. As I've explained above to Alex, I generate APIs in fresh namespaces that don't refer clojure.core and also ns-unmap all java.lang classes, and the generated code also contains `errorf`-forms.

Well, since `ns-unmap` is there, I think it's legit to use it. So that makes CLJ-1232 even more important. But until that gets fixed which requires a common agreement that it is indeed a bug, I'd be very happy if this patch could be accepted. I mean, when it cannot do any harm and doesn't obscure anything but helps at least one person, then why not do it?

Nicola Mometto
August 28, 2014, 7:46 PM

Tassilo, since `errorf` is a macro, that error is probably caused at the expansion point of that macro in a namespace that unmaps 'String.
If that's not the case, please open a ticket in the eastwood repo

Tassilo Horn
August 28, 2014, 7:29 PM

@Alex: 1. is not as weird as it sounds at first. For example, consider you have macros that generate complete APIs for something into some new namespace. Then it can make sense to use a real vanilla namespace, i.e., without referring clojure.core and importing java.lang. With 2. I side with Nicola and consider CLJ-1232 a bug.

@Nicola: Today I've used Eastwood (0.1.4) to lint my project. It crashed when it encountered this definition:

The message was:

So it seems it crashes because `format` has a `^String` return type hint. The namespace containing the `errorf` macro above has no modified ns-imports, i.e., all java.lang classes are imported there, too.

Not Reproducible
Your pinned fields
Click on the next to a field label to start pinning.




Tassilo Horn






Affects versions