From 7375b5a42a77eeb3ac3f085b3d026adbb93ad5a9 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 7 Jul 2021 06:37:58 -0700 Subject: with-resources: undocumented nil skip behavior. Paul A. Patience discovered the hidden "feature" of with-resourcers, that the three-argument form of the binding (var init cleanup) causes the with-resources form to terminate if init returns nil. The (var init) syntax doesn't generate this logic. * stdlib/with-resources.tl (with-resources): Do not emit the when form unless <= 265 compatibility is in effect. * tests/012/oop-mac.tl: New file. * txr.1: Compat note added. --- tests/012/oop-mac.tl | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 tests/012/oop-mac.tl (limited to 'tests/012/oop-mac.tl') diff --git a/tests/012/oop-mac.tl b/tests/012/oop-mac.tl new file mode 100644 index 00000000..d3c3e480 --- /dev/null +++ b/tests/012/oop-mac.tl @@ -0,0 +1,18 @@ +(load "../common") + +(test (with-resources ((a nil (list a)) + (b nil) + (c nil (list c))) + (list a b c)) + (nil nil nil)) + +(test (build + (catch + (with-resources ((a 1 (add a)) + (x nil) + (b 2 (add b)) + (y (throw 'out)) + (z nil t) + (c 3 (add c)))) + (out () (add 4)))) + (2 1 4)) -- cgit v1.2.3