-
-
Notifications
You must be signed in to change notification settings - Fork 141
Description
When evaluating some Fennel code that uses a macro and that macro has a local function defined, Conjure errors with:
; --------------------------------------------------------------------------------
; eval (buf): <path-omitted>/src/app.fnl
; [Compile] .../.config/nvim/bundle/conjure/lua/conjure/nfnl/fennel.lua:1069: attempt to index field 'options' (a nil value)
That erroring line in fennel.lua has me suspect Conjure's initialization of fennel is mixed up if fennel's options haven't been defined yet, maybe through Conjure's (or nfnl's) use of autoload?
Here is a small repro - note this also depends on nfnl.module:
❯ tree -a
.
├── .nfnl.fnl
└── src
├── app.fnl
├── app.lua
└── macros.fnlm
2 directories, 4 files
❯ cat .nfnl.fnl
{:source-file-patterns ["src/*.fnl"]}
❯ cat src/macros.fnlm
(fn foo []
;; Evaluating src/app.fnl in Conjure will succeed if this next line is removed
(fn dummy [] nil)
true)
{: foo}
❯ cat src/app.fnl
(import-macros m :src.macros)
(local {: define} (require :nfnl.module))
(local M (define :src.app))
(fn M.test []
(m.foo))
M
If I comment out the dummy fn above, restart nvim, and try evaluating src/app.fnl, it works fine. At that point, I can then uncomment dummy, evaluate src/app.fnl and evaluation continues to succeed, but the updates to the macro do not seem to propagate. For example, if I change src/macros.fnlm to the following:
(fn foo []
(fn dummy [] nil)
(dummy))
{: foo}
Then re-evaluate src/app.fnl, evaluating (M.test) still returns true from the original version of src/macros.fnlm, rather than nil.
As this repro also uses nfnl, it's worth pointing out that nfnl compilation never errors, and the generated src/app.lua is always up-to-date with the actual macro contents whenever src/macros.fnlm is saved.