abs-oddity's Introduction
Observation: Overriding a core function and then compiling the namespace that contains it leads to an unbound Var exception when that namespace is later loaded and that function run in a later version of Clojure. Background: This popped up because Clojure 1.11 created a core function `abs`. There are some libraries that have compiled artifacts with that function name from previous versions of Clojure that are then run with version 1.11. Notes: * This same behavior happens for all new Vars in core added in 1.11 (update-vals/keys, iteration, etc.) * This same behavior is observable if a use different versions of Clojure and try to override a core function that is new to the later version. For example, I ran a similar set of tests for a function called `add-tap` (added in 1.10) compiled with 1.9 and run with 1.10. --- Deps should have 1.10.3 as dep. In shell: clj -T:build compile-clj clj In REPL ;; Clojure 1.10.3 user=> (require '[fogus.oddity :as o]) nil user=> (o/abs "A") "/tmp/A" user=> o/abs #object[fogus.oddity$abs 0x286b39c2 "fogus.oddity$abs@286b39c2"] Change deps.edn to use Clojure 1.11.0, then relaunch `clj` In REPL ;; Clojure 1.11.0 user=> (require '[fogus.oddity :as o]) nil user=> (o/abs "A") Syntax error compiling at (REPL:1:1). No such var: o/abs user=> o/abs Syntax error compiling at (REPL:0:0). No such var: o/abs **NOTE: There was _NO_ warning about abs override when the `require` was called.** Now while still depending on 1.11.0, clean and recompile clj -T:build clean clj -T:build compile-clj Rerunning the REPL with `clj` ;; Clojure 1.11.0 user=> (require '[fogus.oddity :as o]) WARNING: abs already refers to: #'clojure.core/abs in namespace: fogus.oddity, being replaced by: #'fogus.oddity/abs nil user=> (o/abs "A") "/tmp/A" user=> o/abs #object[fogus.oddity$abs 0x7b60c3e "fogus.oddity$abs@7b60c3e"] --- Some interesting observations while running 1.11.0: (get (ns-map 'fogus.oddity) 'abs) #'clojure.core/abs In 1.10.3 this is #'fogus.oddity/abs If I add a `(:gen-class)` directive to the `fogus.oddity` namespace, then compile with 1.10.3 and run with 1.11.0 I see slightly different behavior. ;; Clojure 1.11.0 user=> (require '[fogus.oddity :as o]) WARNING: abs already refers to: #'clojure.core/abs in namespace: fogus.oddity, being replaced by: #'fogus.oddity/abs nil user=> (o/abs "A") Execution error (IllegalStateException) at user/eval3 (REPL:1). Attempting to call unbound fn: #'fogus.oddity/abs user=> (get (ns-map 'fogus.oddity) 'abs) #'fogus.oddity/abs That is, the override warning happens and the Var is mapped in the ns but the Var is still reported as unbound. The same behavior is observed if I add a main to fogus.oddity that calls its abs and that is compiled with 1.10.3 and a jar created and run with 1.11.0.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.