We're updating the issue view to help you get more done. 

:refer-macros in conjunction with :refer not working

Description

The :refer-macros directive isn't working when used in conjunction with the :refer directive. Compiling a ns-form like

1 2 3 (ns foo (:require [bar :refer [baz] :refer-macros [quux]]))

produces the compiler error

1 Each of :as and :refer options may only be specified once in :require / :require-macros; offending spec: (bar :refer [baz] :refer [quux])

The problem seems to be with analzyer.cljs/desugar-ns-specs. Invoking

1 (desugar-ns-specs '((:require [bar :refer [baz] :refer-macros [quux]])))

returns

1 '((:require-macros (bar :refer [baz] :refer [quux])) (:require (bar :refer [baz])))

instead of

1 '((:require-macros (bar :refer [quux])) (:require (bar :refer [baz])))

Furthermore, there seems to be a typo in the local remove-sugar function on line 1094 [1]: It should probably be

1 (let [[l r] (split-with ...)] ...) ;; no '&' before 'r'

instead of

1 (let [[l & r] (split-with ...)] ...)

Otherwise, something like

1 (desugar-ns-specs '((:require [bar :include-macros true :as b])))

becomes

1 ((:require-macros (bar :as b)) (:require (bar)))

instead of

1 ((:require-macros (bar :as b)) (:require (bar :as b)))

[1] https://github.com/clojure/clojurescript/blob/78d20eebbbad17d476fdce04f2afd7489a507df7/src/clj/cljs/analyzer.clj#L1094

Environment

None

Status

Assignee

Unassigned

Reporter

import

Labels

None

Approval

None

Patch

None

Priority

Minor