From d7ee4e75c22dac847d3c4150728261f1a09e0c0c Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Mon, 27 Apr 2020 19:42:12 -0700 Subject: [PATCH] fix #14142: no more clash with: import os + use of existsDir/dirExists/existsFile/fileExists/findExe in config.nims --- compiler/condsyms.nim | 2 +- lib/pure/os.nim | 6 ++++-- tests/test_nimscript.nims | 8 +++++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/compiler/condsyms.nim b/compiler/condsyms.nim index b7f7100f123c..9807db79a6b3 100644 --- a/compiler/condsyms.nim +++ b/compiler/condsyms.nim @@ -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") diff --git a/lib/pure/os.nim b/lib/pure/os.nim index 83ef238002b1..eb67f284feb6 100644 --- a/lib/pure/os.nim +++ b/lib/pure/os.nim @@ -75,8 +75,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.} diff --git a/tests/test_nimscript.nims b/tests/test_nimscript.nims index a2e8ac94575b..899525549eb6 100644 --- a/tests/test_nimscript.nims +++ b/tests/test_nimscript.nims @@ -69,7 +69,6 @@ import std/[ decls, compilesettings, with, wrapnils ] - block: doAssert "./foo//./bar/".normalizedPath == "foo/bar".unixToNativePath @@ -81,3 +80,10 @@ when false: # #14142 discard findExe("nim") echo "Nimscript imports are successful." + +block: # #14142 + discard existsDir("/usr") + discard dirExists("/usr") + discard existsFile("/usr/foo") + discard fileExists("/usr/foo") + discard findExe("nim")