summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2023-06-01 14:03:17 +0800
committerGitHub <noreply@github.com>2023-06-01 08:03:17 +0200
commitb3e1892eb7f4cb8b2090be7ad12286cc54506e91 (patch)
tree9ed3169a73e376b2e03a2e81176f587a7648eb3f
parent8f760080c546e10ce1cf01dfa1c6165a9b6f1845 (diff)
downloadNim-b3e1892eb7f4cb8b2090be7ad12286cc54506e91.tar.gz
fixes #21977; add sideEffects to dirExists, fileExists and symlinkExists (#21978)
-rw-r--r--lib/std/dirs.nim2
-rw-r--r--lib/std/files.nim2
-rw-r--r--lib/std/private/oscommon.nim6
-rw-r--r--lib/std/symlinks.nim2
4 files changed, 6 insertions, 6 deletions
diff --git a/lib/std/dirs.nim b/lib/std/dirs.nim
index df6107c51..0b0366d44 100644
--- a/lib/std/dirs.nim
+++ b/lib/std/dirs.nim
@@ -8,7 +8,7 @@ from std/private/osdirs import dirExists, createDir, existsOrCreateDir, removeDi
 
 export PathComponent
 
-proc dirExists*(dir: Path): bool {.inline, tags: [ReadDirEffect].} =
+proc dirExists*(dir: Path): bool {.inline, tags: [ReadDirEffect], sideEffect.} =
   ## Returns true if the directory `dir` exists. If `dir` is a file, false
   ## is returned. Follows symlinks.
   result = dirExists(dir.string)
diff --git a/lib/std/files.nim b/lib/std/files.nim
index b2161218b..b61b7dafd 100644
--- a/lib/std/files.nim
+++ b/lib/std/files.nim
@@ -9,7 +9,7 @@ from std/private/osfiles import fileExists, removeFile,
                                 moveFile
 
 
-proc fileExists*(filename: Path): bool {.inline, tags: [ReadDirEffect].} =
+proc fileExists*(filename: Path): bool {.inline, tags: [ReadDirEffect], sideEffect.} =
   ## Returns true if `filename` exists and is a regular file or symlink.
   ##
   ## Directories, device files, named pipes and sockets return false.
diff --git a/lib/std/private/oscommon.nim b/lib/std/private/oscommon.nim
index b747e33f1..c24db3f67 100644
--- a/lib/std/private/oscommon.nim
+++ b/lib/std/private/oscommon.nim
@@ -119,7 +119,7 @@ when not defined(windows):
   const maxSymlinkLen* = 1024
 
 proc fileExists*(filename: string): bool {.rtl, extern: "nos$1",
-                                          tags: [ReadDirEffect], noNimJs.} =
+                                          tags: [ReadDirEffect], noNimJs, sideEffect.} =
   ## Returns true if `filename` exists and is a regular file or symlink.
   ##
   ## Directories, device files, named pipes and sockets return false.
@@ -137,7 +137,7 @@ proc fileExists*(filename: string): bool {.rtl, extern: "nos$1",
 
 
 proc dirExists*(dir: string): bool {.rtl, extern: "nos$1", tags: [ReadDirEffect],
-                                     noNimJs.} =
+                                     noNimJs, sideEffect.} =
   ## Returns true if the directory `dir` exists. If `dir` is a file, false
   ## is returned. Follows symlinks.
   ##
@@ -155,7 +155,7 @@ proc dirExists*(dir: string): bool {.rtl, extern: "nos$1", tags: [ReadDirEffect]
 
 proc symlinkExists*(link: string): bool {.rtl, extern: "nos$1",
                                           tags: [ReadDirEffect],
-                                          noWeirdTarget.} =
+                                          noWeirdTarget, sideEffect.} =
   ## Returns true if the symlink `link` exists. Will return true
   ## regardless of whether the link points to a directory or file.
   ##
diff --git a/lib/std/symlinks.nim b/lib/std/symlinks.nim
index 54ab7b677..60487740c 100644
--- a/lib/std/symlinks.nim
+++ b/lib/std/symlinks.nim
@@ -6,7 +6,7 @@ from paths import Path, ReadDirEffect
 
 from std/private/ossymlinks import symlinkExists, createSymlink, expandSymlink
 
-proc symlinkExists*(link: Path): bool {.inline, tags: [ReadDirEffect].} =
+proc symlinkExists*(link: Path): bool {.inline, tags: [ReadDirEffect], sideEffect.} =
   ## Returns true if the symlink `link` exists. Will return true
   ## regardless of whether the link points to a directory or file.
   result = symlinkExists(link.string)