以下代码失败(在 1.6 和最新的 1.7-alpha4 中均如此)
`
user=> (ns foo)
nil
foo=> (def inc inc)
WARNING: inc already refers to: &'clojure.core/inc in namespace: foo, being replaced by: &'foo/inc
'foo/inc
;; 注意,inc 此时未绑定,从而导致以下异常
foo=> inc
foo=> (ns bar)
nil
bar=> (require ['foo :refer ['inc]])
WARNING: inc already refers to: &'clojure.core/inc in namespace: bar, being replaced by: &'foo/inc
nil
bar=> (inc 8)
IllegalStateException Attempting to call unbound fn: &'foo/inc clojure.lang.Var$Unbound.throwArity (Var.java:43)
`
进一步调查显示 foo/inc 未绑定
foo/inc
=> #
进一步调查还显示,将 (def inc inc) 替换为几乎所有其他内容,例如 (def inc dec), (def inc clojure.core/inc) 或 (def inc (fn (link: n) (+ n 1))),都不会导致异常(但警告仍然存在)。
我预计
a) foo/inc 应该被绑定并具有与 clojure.core/inc 相同的值
b) 在 require foo/inc 时没有错误
c) bar/inc 应该绑定到 foo/inc