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 of assert-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:
ast-source
will give you the line and col numbers. This could then be passed into assert-compile
if desired.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. : )
I think I may have been mixed up when we talked about this in chat. The compiler seems to already do the right thing for this; calls to
assert-compile
are already highlighting the whole call to the macro. (Honestly looking at the code, I'm not sure how! But it is.)It does look like fennel-ls is highlighting the definition or import of the macro rather than the call. This seems like a bug if fennel-ls rather than a bug in the compiler.
Let me know if I'm misunderstanding; if you can find a case where the compiler highlight is wrong I can reinvestigate!