~technomancy/fennel

0d2935bf5f1bdf410566173d59ce8f2cd486e146 — Andrew DeFilippo 2 months ago d4d513d
Initial fix and test case
2 files changed, 4 insertions(+), 3 deletions(-)

M src/fennel/specials.fnl
M test/core.fnl
M src/fennel/specials.fnl => src/fennel/specials.fnl +2 -2
@@ 295,9 295,9 @@ and lacking args will be nil, use lambda for arity-checked functions." true)
(fn SPECIALS.lua [ast _ parent]
  (compiler.assert (or (= (length ast) 2) (= (length ast) 3))
                   "expected 1 or 2 arguments" ast)
  (when (not= (. ast 2) nil)
  (when (not= :nil (-?> (utils.sym? (. ast 2)) utils.deref))
    (table.insert parent {: ast :leaf (tostring (. ast 2))}))
  (when (not= (. ast 3) nil)
  (when (not= :nil (-?> (utils.sym? (. ast 3)) utils.deref))
    (tostring (. ast 3))))

(fn SPECIALS.doc [ast scope parent]

M test/core.fnl => test/core.fnl +2 -1
@@ 227,7 227,8 @@
                   "(xyz (if (and c1 c2) true false) 52))") 52
               "(let [t {} _ (set t.field :let-side)] t.field)" :let-side
               "(local a_0_ (or (getmetatable {}) {:b-c {}}))
                (tset (. a_0_ :b-c) :d 12) (. a_0_ :b-c :d)" 12}]
                (tset (. a_0_ :b-c) :d 12) (. a_0_ :b-c :d)" 12
               "(local x (lua \"y = 4\" \"6\")) (* _G.y x)" 24}]
    (each [code expected (pairs cases)]
      (l.assertEquals (fennel.eval code {:correlate true}) expected code))))