Skip to content
Latchkey

Leiningen "Syntax error macroexpanding" in CI

A macro received a form it could not expand. The arguments do not fit the macro shape, so expansion fails before the resulting code compiles.

What this error means

Compilation fails with Syntax error macroexpanding clojure.core/defn at (app.clj:6:1), naming the macro. It is deterministic.

lein
Syntax error macroexpanding clojure.core/defn at (app.clj:6:1).
(foo [x] ...) - failed: vector? at: [:fn-tail :arity-1 :params]

Common causes

Macro called with the wrong shape

The argument vector or body does not match what the macro (defn, let, deftest) expects, so its spec fails during expansion.

Misused or nested macro

A macro is used in a position or nesting it does not support, producing an invalid expansion.

How to fix it

Match the macro shape

Provide the arguments in the form the macro expects.

app.clj
(defn foo [x]
  (* x x))

Read the spec failure path

  1. Note the at: path in the message to see which part is wrong.
  2. Compare your form to the macro docstring.
  3. Use macroexpand-1 at the REPL to inspect the expansion.

How to prevent it

  • Follow macro arglists exactly.
  • Lint with clj-kondo to catch shape errors.
  • Test macro-heavy code at the REPL before pushing.

Frequently asked questions

What causes ""Syntax error macroexpanding""?
The argument vector or body does not match what the macro (defn, let, deftest) expects, so its spec fails during expansion.
How do I fix "Syntax error macroexpanding"?
Provide the arguments in the form the macro expects.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card