Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting IllegalStateException when reloading a namespace in the REPL

My namespace declaration looks like this:

(ns test.foo
  (:use 
    [clj-http.client :only (get) :as client]
    [net.cgrand.enlive-html :only (select) :as html]))

It works fine in the REPL, the first time I use it. Then, when I modify the code and try the following in the REPL:

(use :reload 'test.foo)

I get:

java.lang.IllegalStateException: get already refers to: #'clj-http.client/get in namespace: test.foo (foo.clj:1)

I'm on windows with counterclockwise and also tried with leiningen (lein repl).

like image 544
Damien Avatar asked Jan 10 '11 15:01

Damien


1 Answers

You should not shadow core fns by accident. You have to be explicit about your intent:

(ns test.foo
  (:refer-clojure :exclude [get]) ; suppress the shadowing warning
  (:require [clojure.core :as core]) ; allow to still reach clojure.core/get through core/get
  (:use 
    [clj-http.client :only (get) :as client]
    [net.cgrand.enlive-html :only (select) :as html]))
like image 103
cgrand Avatar answered Oct 11 '22 04:10

cgrand