Skip to content

Instantly share code, notes, and snippets.

@athos
Last active August 29, 2015 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save athos/10809673 to your computer and use it in GitHub Desktop.
Save athos/10809673 to your computer and use it in GitHub Desktop.
下書き

Libs are blindly added into loaded-libs even if an error occurs during loading

Suppose you have a lib that causes some errors during loading, like the following:

(ns broken-lib)

(} ; this line will cause a reader error

And then, if you require the lib, it would be added into loaded-libs in spite of the reader error, which makes require succeed silently after that.

user=> (contains? (loaded-libs) 'broken-lib)
false
user=> (require 'broken-lib)

CompilerException java.lang.RuntimeException: Unmatched delimiter: }, compiling:
(broken_lib.clj:4:3)
user=> (contains? (loaded-libs) 'broken-lib)
true
user=> (require 'broken-lib)
nil
user=>

Cause:

The patch for CLJ-1116 made the ns macro blindly add the lib being defined into loaded-libs even if an error occurs during loading.

Approach:

modify clojure.core/load-lib so that it removes the lib from loaded-libs on error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment