Ticket created by ~pinkstringmachine on ~technomancy/fennel
This is a continuation from a conversation in the #fennel:matrix.org channel.
Some macros, e.g. no parameters, primitive parameters, etc., do not have an AST to pass to
assert-compile
, which limits its utility. Anecdotally, this limitation has meant that with several macros I've written,fennel-ls
raises compile errors with code hints on the line where the macros are imported (import-macros
), seemingly because it's unsure what line is relevant. My guess is that the primary use ofassert-compile
is to validate that the macro its called in is correctly structured as well, so I'm wondering if there are ways for us maximize for the presumably most common case.Two potential options:
- The AST of the macro that is being evaluated is available for itself on the compile global environment, such that
ast-source
will give you the line and col numbers. This could then be passed intoassert-compile
if desired.- If no AST is provided to a
assert-compile
call, it will default to the AST source of the macro from which it is called.The nuances of whether or not we can expose AST information like that and what the consequences would be are beyond my scope of understanding, but I wanted to drop this in here for posterity. : )