Skip to content

Commit

Permalink
Make macroexpand1 crash if macro isn't callable.
Browse files Browse the repository at this point in the history
Unless it's None, which will be interpreted as no macro by that name being present.
This is more consistent with compiler behavior.
The check should also be a little bit faster.
  • Loading branch information
gilch committed Jul 20, 2024
1 parent 2d0b493 commit 3a448f6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/hissp/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,9 +609,9 @@ def macroexpand1(form, ns=None):
if type(form) is not tuple or not form:
return form
head, *tail = form
if callable(macro := Compiler.get_macro(form[0], ns)):
return macro(*tail)
return form
if (macro := Compiler.get_macro(form[0], ns)) is None:
return form
return macro(*tail)


def macroexpand(form, ns=None):
Expand Down

0 comments on commit 3a448f6

Please sign in to comment.