-
-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix module return value #91
Conversation
f3c9683
to
380523a
Compare
Whoops, accidentally force-pushed without any changes which closed the PR 😅. Sorry if closing/reopening/commenting spams your email. Anyway the latest commit removes the formatting changes introduced by parinfer. Unfortunately some tests are now failing. From here I'll need some input, if you like these changes then we should probably modify the failing tests. Also one of the tests complains about module not existing so it's possible this can be solved in a smarter way than my hacky macro. I don't have much experience with the fennel compiler so I'll read up and see if I come up with anything. edit: speaking of that reading... the below commit uses second edit: in-scope actually didn't work for this unfortunately |
Will look soon! Away visiting family + working remotely at the moment so will hopefully get time later in the week 😊 thank you for looking into this! |
Now, rather than using (or *module* original-return), wrap-module-body just wraps the last expression in yet another macro wrap-last-expr which, when evaluated, has access to the scope as-of the last expression, so we can test for *module* using (get-scope). This way if *module* doesn't exist we can just leave everything untouched and if it does, just append *module* so it gets returned.
So, the latest commit has this at a state that I'm very happy with. Now I'm wrapping the body in a macro that wraps the last expression in another macro which can properly access the scope to check for
Also, I went ahead and implemented #66 for fun. No rush on any of this, enjoy your time away :) |
I'm making some rename changes locally and reviewing, looking good! I've also wrapped Aniseeds internally bootstrapped files in the same macros so they get the same protection. |
Merged and compiled into Conjure's |
I really like that it ensures some consistency across ALL files, no more slight chance of returning the wrong table. |
Continuation of #90
wrap-module-body
macrocompile.macros-prefix
to wrap body inwrap-module-body
. That should probably be moved to its own function(?) or the name ofmacros-prefix
should be changedThis appears to generate the right lua for my dotfiles. It looks like parinfer changed the files more than necessary so I'll have to fix that tomorrow.
See:
https://github.com/harrygallagher4/nvim/blob/95ba7461baf53393bc4f6861d19565b1a940a098/fnl/dotfiles/init.fnl (module that has a return value other than
*module*
, now with*module*
removed)https://gist.github.com/harrygallagher4/847440c11921153d8f4fc6871bb49820#file-init-lua-L34-L38 (compiled lua)
https://github.com/harrygallagher4/nvim/blob/2cf6ff701aacb8a5cdf734216c2944c4f3f99804/fnl/dotfiles/test.fnl (non-aniseed module)
https://gist.github.com/harrygallagher4/847440c11921153d8f4fc6871bb49820#file-test-lua (compiled)