Skip to content

Stripping leading commas breaks Fennel macros #201

@dundalek

Description

@dundalek

The formatter works surprisinly well for Fennel (a Clojure-inspired dialect for Lua), I like the output much better than fnlfmt.
The only issue I encountered is difference in macros, Fennel uses comma for unqoute: ,form is like ~form in Clojure meaning leading commas are significant. When formatter strips them it can break a macro.

Example:

(macro when-let-repro [binding & body]
  (let [[binding-form expr] binding]
    `(let [temp# ,expr]
       (when temp#
         (let [,binding-form temp#]
           ,(unpack body))))))

Leading comma gets stripped:

@@ -2,5 +2,5 @@
   (let [[binding-form expr] binding]
     `(let [temp# ,expr]
        (when temp#
-         (let [,binding-form temp#]
+         (let [binding-form temp#]
            ,(unpack body))))))

Unfortunately Fennel does not support metadata, so adding #_:standard-clj/ignore causes compile error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions