diff --git a/test/test-utilities.script b/test/test-utilities.script index 168a82738e8199e49dd70d6a00a99b4b6cfedd91..f0b1befb3b493d801ec94c023ac43e858b8ad350 100644 --- a/test/test-utilities.script +++ b/test/test-utilities.script @@ -468,6 +468,11 @@ (assert-equal (read-file-lines p) '("Same thing with :close-stream")) p)))))) +(let ((pn4 (uiop:with-temporary-file (:pathname pn :direction :output :prefix "WTF4") + :close-stream + pn))) + (assert (not (probe-file pn4)))) + (DBG :ensure-gethash) (let ((h (make-hash-table :test 'equal))) (assert-equal (multiple-value-list (gethash 1 h 2)) '(2 nil)) diff --git a/uiop/stream.lisp b/uiop/stream.lisp index 825cccd179207ae80cf4c82698bb25f52aebf919..b0dd6cfdaf985bb950d978251db109065ce50c9b 100644 --- a/uiop/stream.lisp +++ b/uiop/stream.lisp @@ -627,13 +627,13 @@ Finally, the file will be deleted, unless the KEEP argument when CALL-FUNCTION'e ;; or the non-local return causes the file creation to be undone. (setf results (multiple-value-list (if want-pathname-p - (funcall thunk stream pathname) - (funcall thunk stream))))))) + (call-function thunk stream pathname) + (call-function thunk stream))))))) ;; if we don't want a stream, then we must call the thunk *after* ;; the stream is closed, but only if it was successfully opened. (when okp (when (and want-pathname-p (not want-stream-p)) - (setf results (multiple-value-list (funcall thunk okp)))) + (setf results (multiple-value-list (call-function thunk okp)))) ;; if the stream was successfully opened, then return a value, ;; either one computed already, or one from AFTER, if that exists. (if after @@ -664,6 +664,8 @@ Upon success, the KEEP form is evaluated and the file is is deleted unless it ev (after (when afterp (subseq body (1+ afterp)))) (beforef (gensym "BEFORE")) (afterf (gensym "AFTER"))) + (when (eql afterp 0) + (style-warn ":CLOSE-STREAM should not be the first form of BODY in WITH-TEMPORARY-FILE. Instead, do not provide a STREAM.")) `(flet (,@(when before `((,beforef (,@(when streamp `(,stream)) ,@(when pathnamep `(,pathname))) ,@(when after `((declare (ignorable ,pathname))))