See the attached patch.

--
Pietro Cerutti
I have pledged to give 10% of income to effective charities
and invite you to join me - https://givingwhatwecan.org
>From 2218105f82fd715f00680206a9a0515c5741e127 Mon Sep 17 00:00:00 2001
From: Pietro Cerutti <[email protected]>
Date: Mon, 6 Jan 2025 14:10:24 +0000
Subject: [PATCH] Fix the return types of a couple of (chicken file) procedures

According to the docs, `delete-file*` is supposed to return #t on success.
However, it has `delete-file` in tail position, which in turn has `unless` in
tail position.  I think this was an oversight and `delete-file` should have
its argument in tail position instead.

The types.db incorrectly declare `delete-directory` as returning a string.
---
 file.scm                     | 4 ++--
 manual/Module (chicken file) | 2 +-
 types.db                     | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/file.scm b/file.scm
index 2a212292..563724d8 100644
--- a/file.scm
+++ b/file.scm
@@ -228,8 +228,8 @@ EOF
   (unless (eq? 0 (##core#inline "C_remove" (##sys#make-c-string filename 
'delete-file)))
     (##sys#signal-hook/errno
      #:file-error (##sys#update-errno) 'delete-file
-     (##sys#string-append "cannot delete file - " strerror) filename)
-    filename))
+     (##sys#string-append "cannot delete file - " strerror) filename))
+  filename)
 
 (define (delete-file* file)
   (and (file-exists? file) (delete-file file)))
diff --git a/manual/Module (chicken file) b/manual/Module (chicken file)
index e2804508..8fc434a9 100644
--- a/manual/Module (chicken file)      
+++ b/manual/Module (chicken file)      
@@ -70,7 +70,7 @@ not exist, an error is signaled.
 
 <procedure>(delete-file* STRING)</procedure>
 
-If the file with pathname {{STRING}} exists, it is deleted and {{#t}}
+If the file with pathname {{STRING}} exists, it is deleted and {{STRING}}
 is returned.  If the file does not exist, nothing happens and {{#f}}
 is returned.
 
diff --git a/types.db b/types.db
index 5ee90b8f..3d10f564 100644
--- a/types.db
+++ b/types.db
@@ -1668,9 +1668,9 @@
 (chicken.file#create-directory (#(procedure #:clean #:enforce) 
chicken.file#create-directory (string #!optional *) string))
 (chicken.file#create-temporary-directory (#(procedure #:clean #:enforce) 
chicken.file#create-temporary-directory () string))
 (chicken.file#create-temporary-file (#(procedure #:clean #:enforce) 
chicken.file#create-temporary-file (#!optional string) string))
-(chicken.file#delete-directory (#(procedure #:clean #:enforce) 
chicken.file#delete-directory (string #!optional *) string))
+(chicken.file#delete-directory (#(procedure #:clean #:enforce) 
chicken.file#delete-directory (string #!optional *) undefined))
 (chicken.file#delete-file (#(procedure #:clean #:enforce) 
chicken.file#delete-file (string) string))
-(chicken.file#delete-file* (#(procedure #:clean #:enforce) 
chicken.file#delete-file* (string) *))
+(chicken.file#delete-file* (#(procedure #:clean #:enforce) 
chicken.file#delete-file* (string) (or false string)))
 (chicken.file#directory-exists? (#(procedure #:clean #:enforce) 
chicken.file#directory-exists? (string) (or false string)))
 (chicken.file#file-exists? (#(procedure #:clean #:enforce) 
chicken.file#file-exists? (string) (or false string)))
 (chicken.file#find-files (#(procedure #:enforce) chicken.file#find-files 
(string #!rest) list))
-- 
2.47.1

Reply via email to