summary refs log tree commit diff stats
path: root/lib/std/syncio.nim
diff options
context:
space:
mode:
authorBung <crc32@qq.com>2022-08-30 00:09:14 +0800
committerGitHub <noreply@github.com>2022-08-29 18:09:14 +0200
commit04e4a5ec0e35fc7e1c346c2d002e8487b4b48cb5 (patch)
tree8e5bffa3e6412bdbbad2beb9f3dddef85a0861fc /lib/std/syncio.nim
parentcc81866da1d045c6702e1c3814fa8ea3e15d53da (diff)
downloadNim-04e4a5ec0e35fc7e1c346c2d002e8487b4b48cb5.tar.gz
fix #19600 No error checking on fclose (#19836)
* fix #19600 No error checking on fclose

* add IOError to open
Diffstat (limited to 'lib/std/syncio.nim')
-rw-r--r--lib/std/syncio.nim6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/std/syncio.nim b/lib/std/syncio.nim
index 22e981198..4eeb1778d 100644
--- a/lib/std/syncio.nim
+++ b/lib/std/syncio.nim
@@ -324,7 +324,9 @@ const
 proc close*(f: File) {.tags: [], gcsafe.} =
   ## Closes the file.
   if not f.isNil:
-    discard c_fclose(f)
+    let x = c_fclose(f)
+    if x < 0:
+      checkErr(f)
 
 proc readChar*(f: File): char {.tags: [ReadIOEffect].} =
   ## Reads a single character from the stream `f`. Should not be used in
@@ -689,7 +691,7 @@ when defined(posix) and not defined(nimscript):
 
 proc open*(f: var File, filename: string,
           mode: FileMode = fmRead,
-          bufSize: int = -1): bool {.tags: [], raises: [], benign.} =
+          bufSize: int = -1): bool {.tags: [], raises: [IOError], benign.} =
   ## Opens a file named `filename` with given `mode`.
   ##
   ## Default mode is readonly. Returns true if the file could be opened.