[Git][cmucl/cmucl][master] 2 commits: Avoid inserting NIL into simple LOOP from FORMAT

Raymond Toy (@rtoy) gitlab at common-lisp.net
Tue Feb 21 23:25:34 UTC 2023



Raymond Toy pushed to branch master at cmucl / cmucl


Commits:
be8cb5d0 by Tarn W. Burton at 2023-02-21T07:48:12-05:00
Avoid inserting NIL into simple LOOP from FORMAT

- - - - -
0d3cbc39 by Raymond Toy at 2023-02-21T23:25:27+00:00
Merge branch 'fix-format-nil' into 'master'

Fix #165: Avoid inserting NIL into simple LOOP from FORMAT

See merge request cmucl/cmucl!114
- - - - -


2 changed files:

- src/code/format.lisp
- tests/printer.lisp


Changes:

=====================================
src/code/format.lisp
=====================================
@@ -399,7 +399,8 @@
 	  (form new-directives)
 	  (expand-directive (car remaining-directives)
 			    (cdr remaining-directives))
-	(push form results)
+	(when form
+          (push form results))
 	(setf remaining-directives new-directives)))
     (reverse results)))
 


=====================================
tests/printer.lisp
=====================================
@@ -113,3 +113,16 @@
 
 (define-test sub-output-integer.1
     (assert-prints "-536870912" (princ most-negative-fixnum)))
+
+;;; Simple LOOP requires only compound forms. Hence NIL is not
+;;; permitted. Some FORMAT directives (like newline) return NIL
+;;; as the form when they have nothing to add to the body.
+;;; Normally this is fine since BLOCK accepts NIL as a form. On
+;;; the other hand, when the newline directive is inside of an
+;;; iteration directive this will produce something like
+;;; (LOOP (fu) nil (bar)) which is not acceptable. To verify
+;;; that this is not happening we make sure we are not getting
+;;; (BLOCK NIL NIL) since this is easier to test for.
+(define-test format-no-nil-form.1
+    (assert-equal '(block nil) (third (second (macroexpand-1 '(formatter "~
+"))))))



View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/4be1d90cfdf7c67efb30a3571a8ababfd60a6476...0d3cbc39b614c0d7ef7e2edb9291f3644c397273

-- 
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/4be1d90cfdf7c67efb30a3571a8ababfd60a6476...0d3cbc39b614c0d7ef7e2edb9291f3644c397273
You're receiving this email because of your account on gitlab.common-lisp.net.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/cmucl-cvs/attachments/20230221/a970be4c/attachment-0001.html>


More information about the cmucl-cvs mailing list