Skip to content

Commit 17c1c35

Browse files
authored
Don't throw exception for list without symbol first in macroexpansion (#132)
1 parent 9d24c00 commit 17c1c35

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

basilisp/compiler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ def _assert_recur_is_tail(ctx: CompilerContext, form: lseq.Seq) -> None: # noqa
600600
for i, child in enumerate(form): # pylint:disable=too-many-nested-blocks
601601
listlen += 1
602602
if isinstance(child, (llist.List, lseq.Seq)):
603-
if _is_sym_macro(ctx, child.first):
603+
if isinstance(child.first, sym.Symbol) and _is_sym_macro(ctx, child.first):
604604
continue
605605
elif child.first == _RECUR:
606606
if first_recur_index is None:

tests/compiler_test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,10 @@ def test_fn_call(ns_var: Var):
267267
assert fvar == "bleep"
268268

269269

270+
def test_macro_expansion(ns_var: Var):
271+
assert llist.l(1, 2, 3) == lcompile("((fn [] '(1 2 3)))")
272+
273+
270274
def test_if(ns_var: Var):
271275
assert lcompile("(if true :a :b)") == kw.keyword("a")
272276
assert lcompile("(if false :a :b)") == kw.keyword("b")

0 commit comments

Comments
 (0)