Skip to content

Commit

Permalink
fix nim-lang#14142: no more clash with: import os + use of existsDir/…
Browse files Browse the repository at this point in the history
…dirExists/existsFile/fileExists/findExe in config.nims
  • Loading branch information
timotheecour committed Apr 28, 2020
1 parent 065a6af commit 9db29cb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion compiler/condsyms.nim
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ proc initDefines*(symbols: StringTableRef) =
defineSymbol("nimHasUserErrors")
defineSymbol("nimUncheckedArrayTyp")
defineSymbol("nimHasTypeof")
defineSymbol("nimErrorProcCanHaveBody")
defineSymbol("nimErrorProcCanHaveBody") # since #9665 but now unused
defineSymbol("nimHasInstantiationOfInMacro")
defineSymbol("nimHasHotCodeReloading")
defineSymbol("nimHasNilSeqs")
Expand Down
6 changes: 4 additions & 2 deletions lib/pure/os.nim
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,10 @@ elif defined(posix):
else:
{.error: "OS module not ported to your operating system!".}

when weirdTarget and defined(nimErrorProcCanHaveBody):
{.pragma: noNimScript, error: "this proc is not available on the NimScript target".}
when weirdTarget:
template noNimScript(body): untyped = discard
# Adding a `disable` template and `{.pragma: noNimScript, disable.}`
# doesn't work pending https://github.com/timotheecour/Nim/issues/142
else:
{.pragma: noNimScript.}

Expand Down
10 changes: 10 additions & 0 deletions tests/test_nimscript.nims
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# This nimscript is used to test if the following modules can be imported
# http://nim-lang.org/docs/nims.html

{.push warning[UnusedImport]: off.}
import algorithm
import base64
import colors
Expand All @@ -22,7 +23,16 @@ import unicode
import uri
import macros

# {.pop.} # xxx `pop` would resurface UnusedImport warnings

block:
doAssert "./foo//./bar/".normalizedPath == "foo/bar".unixToNativePath

echo "Nimscript imports are successful."

block: # #14142
discard existsDir("/usr")
discard dirExists("/usr")
discard existsFile("/usr/foo")
discard fileExists("/usr/foo")
discard findExe("nim")

0 comments on commit 9db29cb

Please sign in to comment.