Skip to content

Commit

Permalink
CLJS-1004: warning about single segment namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
swannodette committed Feb 5, 2015
1 parent 647f775 commit dc47f1f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/clj/cljs/analyzer.clj
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@
:invalid-arithmetic true
:protocol-invalid-method true
:protocol-duped-method true
:protocol-multiple-impls true})
:protocol-multiple-impls true
:single-segment-namespace true})

(declare message namespaces)

Expand Down Expand Up @@ -173,6 +174,10 @@
[warning-type info]
(str "Cannot invoke type constructor " (-> info :fexpr :info :name) " as function "))

(defmethod error-message :single-segment-namespace
[warning-type info]
(str (:name info) " is a single segment namespace"))

(defn ^:private default-warning-handler [warning-type env extra]
(when (warning-type *cljs-warnings*)
(when-let [s (error-message warning-type extra)]
Expand Down Expand Up @@ -1279,6 +1284,8 @@
[_ env [_ name & args :as form] _ opts]
(when-not (symbol? name)
(throw (error env "Namespaces must be named by a symbol.")))
(when (= 1 (count (string/split (clojure.core/name name) #"\.")))
(warning :single-segment-namespace env {:name name}))
(let [docstring (if (string? (first args)) (first args))
args (if docstring (next args) args)
metadata (if (map? (first args)) (first args))
Expand Down

0 comments on commit dc47f1f

Please sign in to comment.