ccl
ccl copied to clipboard
`ccl:macroexpand-all` and `tagbody`
There are two problems caused by not treating forms in the tagbody correctly.
ccl:macroexpand-allexpands symbols that have a symbol-macro definition intagbodywhen they are in the tag position.ccl:macroexpand-alldoesn't "protect" macroexpansion of the macros intagbodythat can becom a tag (symbols and integers).
(ccl:macroexpand-all
'(symbol-macrolet ((tag (tag-expanded)))
(tagbody tag)))
; => (PROGN (TAGBODY (TAG-EXPANDED)))
(ccl:macroexpand-all
'(macrolet ((not-tag () 'tag-expanded))
(tagbody (not-tag))))
; => (PROGN (TAGBODY TAG-EXPANDED))
The determination of which elements of the body are tags and which are statements is made prior to any macro expansion of that element. If a statement is a macro form and its macro expansion is an atom, that atom is treated as a statement, not a tag.
-- CLHS, tagbody: https://www.lispworks.com/documentation/HyperSpec/Body/s_tagbod.htm
That means that
tagintagbodyshould not be expanded.(not-tag)expansion should be "protected" so that it doesn't become a tag, for example viaprogn.
Tested on CCL 1.13
(lisp-implementation-version) ; => "Version 1.13 (v1.13) LinuxX8664"
This affects quite a few other implementations, see this table (two last columns): https://plaster.tymoon.eu/view/4637.