Commit 20ef584b authored by Henrik Hjelte's avatar Henrik Hjelte
Browse files

test to detect bug, more than one nil tag in tagbody

parent 0e93db17
......@@ -1715,4 +1715,45 @@
do (loop-finish)))
;; Misc tests to make sure that bugs don't reappear
(defmacro problem-because-i-return-nil (&rest args)
(declare (ignore args))
(deftest tagbody.nil-tags
;; Allegro (correctly) won't compile when a tag (typically NIL) is used more than once in a tagbody.
(labels ((find-tagbody (form)
((and (listp form)
(eq (first form)
((listp form)
(iter (for x in (rest form))
(for y = (find-tagbody x))
(when y
(return y))
(until y)))
(t nil)))
(all-tagbody-tags (form)
(iter (for tag-or-form in (rest (find-tagbody form)))
(when (symbolp tag-or-form)
(collect tag-or-form)))))
(let* ((form (macroexpand '
(iter (for x in '(1 2 3))
(+ x x)
(tags (all-tagbody-tags form))
(test-result t))
(iter (for tag in tags)
(when (not (= 1 (funcall #'count tag tags)))
(setf test-result nil)
(format t "Tag ~a is used more than once in the tagbody ~a" tag (find-tagbody form))))
;;; arch-tag: "b8b1db2d-313c-11d8-abb9-000c76244c24"
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment