   "Recursively checks that an expression uses correct arity, and returns a
   lazy seq of the erroneous calls as ExceptionInfos."
   [expr-name expr]
-  (cond (not= :op (:type expr)) ()
-        (-> expr meta :alias-expansion) () ;; Should be handled in resp. aliases
-        :else
-        (let [some-exn (op-arity-exn expr-name expr)]
-          (->> (:args expr)
-               (map #(check-expr-arity expr-name %))
-               (apply concat)
-               (concat some-exn)))))
+  (if (unexpanded-op? expr)
+    (let [some-exn (op-arity-exn expr-name expr)]
+      (->> (:args expr)
+           (map #(check-expr-arity expr-name %))
+           (apply concat)
+           (concat some-exn)))))
 
 (defn check-arity
   "Checks that all operations have correct arity. Returns a sequence of

  "Recursively checks that an expression has correct input arg types, and
  returns a lazy seq of the erroneous calls as ExceptionInfos."
  [expr]
  (if (and (= :op (:type expr))
           (not (-> expr meta :alias-expansion)))
    (concat
     (case (:value expr)
       (:cat :opt :plus :star :or) nil

(ns smallex.grammar-checks)

(defn- unexpanded-op? [expr]
  (and (= :op (:type expr))
       (not (-> expr meta :alias-expansion))))

(def ^:private single-arg-op?
  "Returns true if the op is a single-argument op, false otherwise."
