Clojure

autodoc fails to load clojure/spec.clj

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Critical Critical
  • Resolution: Completed
  • Affects Version/s: Release 1.9
  • Fix Version/s: Release 1.9
  • Component/s: None
  • Labels:
  • Approval:
    Vetted

Description

Reported by Tom F for the autodoc process. The following (essentially) is what autodoc is doing that currently blows up:

tom@renoir:~/src/clj/autodoc-work-area/clojure/src$ java -cp clojure.jar clojure.main
Clojure 1.9.0-master-SNAPSHOT
user=> (load-file "src/clj/clojure/spec.clj")
CompilerException java.lang.IllegalArgumentException: No implementation of method: :conform* \
of protocol: #'clojure.spec/Spec found for class: clojure.spec$regex_spec_impl$reify__14279, \
compiling:(/home/tom/src/clj/autodoc-work-area/clojure/src/src/clj/clojure/spec.clj:684:1)

Cause: There is code in Compiler.macroexpand() with the intention to suspend spec checking inside clojure.spec. However, it is currently doing an exact path match on SOURCE_PATH. In the load-file call above, this ends up being an absolute path.

Approach: Use the system property -Dclojure.spec.skip-macros=true to avoid encountering this issue

Activity

Hide
Alex Miller added a comment -

Removing "code" tag for patch as this is not good to screen yet. While the patch kind of works, it would be good if there were a more reliable way to omit spec checking in the scope of the spec namespace. Rather than checking the source path, it would be much better to instead check the current ns. This works EXCEPT during the macro expansion of ns (which has a spec) in spec itself. At that point you have not yet evaluated the (in-ns 'clojure.spec) (since that's what the ns macro is expanding to). Really, all of this is a problem at exactly one point - compiling clojure.spec itself. Another option might be some way to suspend macro spec checking altogether (which might be a generally useful feature).

Show
Alex Miller added a comment - Removing "code" tag for patch as this is not good to screen yet. While the patch kind of works, it would be good if there were a more reliable way to omit spec checking in the scope of the spec namespace. Rather than checking the source path, it would be much better to instead check the current ns. This works EXCEPT during the macro expansion of ns (which has a spec) in spec itself. At that point you have not yet evaluated the (in-ns 'clojure.spec) (since that's what the ns macro is expanding to). Really, all of this is a problem at exactly one point - compiling clojure.spec itself. Another option might be some way to suspend macro spec checking altogether (which might be a generally useful feature).
Hide
Alex Miller added a comment -

Lot of stuff has changed since this was filed. The repro for this is now something you can do in the spec.alpha project (this was filed before spec split):

mvn -q dependency:build-classpath -Dmdep.outputFile=cp
java -cp `cat cp` clojure.main

Clojure 1.9.0-beta3
user=> (load-file "src/main/clojure/clojure/spec/alpha.clj")
CompilerException java.lang.Exception: #object[clojure.spec.alpha$and_spec_impl$reify__863 0x1353488e "clojure.spec.alpha$and_spec_impl$reify__863@1353488e"] is not a fn, expected predicate fn, compiling:(/Users/alex/code/spec.alpha/src/main/clojure/clojure/spec/alpha.clj:78:1)

Since 1.9.0-beta3, you can now avoid this problem by using the System property to turn off spec macro checking while compiling spec itself:

java -cp `cat cp` -Dclojure.spec.skip-macros=true clojure.main

Clojure 1.9.0-beta3
user=> (load-file "src/main/clojure/clojure/spec/alpha.clj")
#'clojure.spec.alpha/assert

This should be the approach used here.

Show
Alex Miller added a comment - Lot of stuff has changed since this was filed. The repro for this is now something you can do in the spec.alpha project (this was filed before spec split):
mvn -q dependency:build-classpath -Dmdep.outputFile=cp
java -cp `cat cp` clojure.main

Clojure 1.9.0-beta3
user=> (load-file "src/main/clojure/clojure/spec/alpha.clj")
CompilerException java.lang.Exception: #object[clojure.spec.alpha$and_spec_impl$reify__863 0x1353488e "clojure.spec.alpha$and_spec_impl$reify__863@1353488e"] is not a fn, expected predicate fn, compiling:(/Users/alex/code/spec.alpha/src/main/clojure/clojure/spec/alpha.clj:78:1)
Since 1.9.0-beta3, you can now avoid this problem by using the System property to turn off spec macro checking while compiling spec itself:
java -cp `cat cp` -Dclojure.spec.skip-macros=true clojure.main

Clojure 1.9.0-beta3
user=> (load-file "src/main/clojure/clojure/spec/alpha.clj")
#'clojure.spec.alpha/assert
This should be the approach used here.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: