Skip to content

Commit a4d266f

Browse files
committed
Worked around a possible Fennel REPL bug by cloning _G and passing that as :env
1 parent 9065ec6 commit a4d266f

File tree

4 files changed

+34
-2
lines changed

4 files changed

+34
-2
lines changed

fnl/nfnl/repl.fnl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
{:pp core.identity
2424
:readChunk coroutine.yield
2525

26+
;; Possible Fennel bug? We need to clone _G or multiple REPLs interfere with each other sometimes.
27+
:env (core.merge _G)
28+
2629
:onValues
2730
(fn [results]
2831
(set results-to-return (core.concat results-to-return results)))

fnl/spec/nfnl/repl_spec.fnl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
(local {: describe : it} (require :plenary.busted))
2+
(local core (require :nfnl.core))
23
(local assert (require :luassert.assert))
34
(local repl (require :nfnl.repl))
45

@@ -17,4 +18,17 @@
1718
(assert.are.same nil (r))
1819
(assert.are.same nil (r ":foo"))
1920

21+
nil))
22+
23+
(it "can handle function references, tables and multiple REPLs"
24+
(fn []
25+
(let [r1 (repl.new)
26+
r2 (repl.new)
27+
code "(fn a []) (fn b []) {: a : b}"
28+
pat "%[#<function: 0x%x+>%s+#<function: 0x%x+>%s+{:%w #<function: 0x%x+> :%w #<function: 0x%x+>}%]"]
29+
(assert.matches pat (core.pr-str (r1 code)))
30+
(assert.matches pat (core.pr-str (r2 code)))
31+
(assert.matches pat (core.pr-str (r1 code)))
32+
(assert.matches pat (core.pr-str (r2 code))))
33+
2034
nil))))

lua/nfnl/repl.lua

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lua/spec/nfnl/repl_spec.lua

Lines changed: 16 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)