Details
Description
When performing AOT compilation, if the namespace being compiled or one of the namespaces :required by it defines a public function named 'load', the compiler will crash with a NullPointerException.
The following code demonstrates this:
(ns ca.ancilla.kessler.core (:gen-class)) (defn load [x] x) (defn -main [& args] 0)
When run directly, with 'clojure -m ca.ancilla.kessler.core' or 'clojure ca/ancilla/kessler/core.clj', it runs as expected. When loaded with 'clojure -i' and (compile)d, however, or when automatically compiled by 'lein run', it results in a NullPointerException (the complete stack trace is attached).
This occurs whether or not 'load' or actually called. It does not, however, occur if 'load' is private.
Attachments
Activity
Stuart Halloway
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Resolution | Declined [ 2 ] | |
| Status | Open [ 1 ] | Closed [ 6 ] |
If you add (:refer-clojure :exclude [load]) to the (ns), it works fine:
(ns ca.ancilla.kessler.core (:refer-clojure :exclude [load]) (:gen-class))
(defn load [x] x)
(defn -main [& args] 0)
Thanks to llasram on IRC for discovering this.