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.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →