From 5492190bc63326069233a8aaf9f2e567cfc555f8 Mon Sep 17 00:00:00 2001 From: Dennis Felsing Date: Mon, 8 Jan 2018 10:49:00 +0100 Subject: [PATCH 1/5] Fix lists of paths in posix environment (#7034) Empty paths in a colon separated list would be considered as the current directory, so have to ensure $PATH and $LD_LIBRARY_PATH are not empty before separating it with : --- .gitlab-ci.yml | 2 +- .travis.yml | 2 +- ci/build.sh | 2 +- ci/deps.sh | 2 +- koch.nim | 4 ++-- tests/testament/categories.nim | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 76c94c8e75..c37b4c8d4b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,7 +8,7 @@ stages: .linux_set_path: &linux_set_path_def before_script: - - export PATH=$(pwd)/bin:$PATH + - export PATH=$(pwd)/bin${PATH:+:$PATH} tags: - linux diff --git a/.travis.yml b/.travis.yml index 6b8cdbe03b..a3fa3f1da1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,7 +30,7 @@ before_script: - sh build.sh - cd .. - sed -i -e 's,cc = gcc,cc = clang,' config/nim.cfg - - export PATH=$(pwd)/bin:$PATH + - export PATH=$(pwd)/bin${PATH:+:$PATH} script: - nim c koch - ./koch boot diff --git a/ci/build.sh b/ci/build.sh index a0fee14977..6321fffba8 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -6,7 +6,7 @@ cd csources sh build.sh cd .. # Add Nim to the PATH -export PATH=$(pwd)/bin:$PATH +export PATH=$(pwd)/bin${PATH:+:$PATH} # Bootstrap. nim -v nim c koch diff --git a/ci/deps.sh b/ci/deps.sh index 7471785a0d..f0f831a2a3 100644 --- a/ci/deps.sh +++ b/ci/deps.sh @@ -7,7 +7,7 @@ apt-get install -y -qq build-essential git libcurl4-openssl-dev libsdl1.2-dev li gcc -v -export PATH=$(pwd)/bin:$PATH +export PATH=$(pwd)/bin${PATH:+:$PATH} # Nimble deps nim e install_nimble.nims diff --git a/koch.nim b/koch.nim index 7bb7ea4024..d51b902ee8 100644 --- a/koch.nim +++ b/koch.nim @@ -97,7 +97,7 @@ proc exec(cmd: string, errorcode: int = QuitFailure, additionalPath = "") = if not absolute.isAbsolute: absolute = getCurrentDir() / absolute echo("Adding to $PATH: ", absolute) - putEnv("PATH", prevPath & PathSep & absolute) + putEnv("PATH", (if prevPath.len > 0: prevPath & PathSep else: "") & absolute) echo(cmd) if execShellCmd(cmd) != 0: quit("FAILURE", errorcode) putEnv("PATH", prevPath) @@ -402,7 +402,7 @@ proc winReleaseArch(arch: string) = template withMingw(path, body) = let prevPath = getEnv("PATH") - putEnv("PATH", path & PathSep & prevPath) + putEnv("PATH", (if path.len > 0: path & PathSep else: "") & prevPath) try: body finally: diff --git a/tests/testament/categories.nim b/tests/testament/categories.nim index 33b93e3c4d..42e19d3dd0 100644 --- a/tests/testament/categories.nim +++ b/tests/testament/categories.nim @@ -90,7 +90,7 @@ proc runBasicDLLTest(c, r: var TResults, cat: Category, options: string) = # posix relies on crappy LD_LIBRARY_PATH (ugh!): var libpath = getEnv"LD_LIBRARY_PATH".string # Temporarily add the lib directory to LD_LIBRARY_PATH: - putEnv("LD_LIBRARY_PATH", "tests/dll:" & libpath) + putEnv("LD_LIBRARY_PATH", "tests/dll" & (if libpath.len > 0: ":" & libpath else: "")) defer: putEnv("LD_LIBRARY_PATH", libpath) var nimrtlDll = DynlibFormat % "nimrtl" safeCopyFile("lib" / nimrtlDll, "tests/dll" / nimrtlDll) From ce31789431d1a7925a047fa31779a499f8dcf437 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Str=C3=B8mberg?= Date: Mon, 8 Jan 2018 13:30:09 +0100 Subject: [PATCH 2/5] Ast and concrete syntax different. Change variable name to a from v, to match the ast and other examples. --- doc/astspec.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/astspec.txt b/doc/astspec.txt index 57f6b9d8c9..6d755c2e20 100644 --- a/doc/astspec.txt +++ b/doc/astspec.txt @@ -918,7 +918,7 @@ This is equivalent to ``var``, but with ``nnkLetSection`` rather than Concrete syntax: .. code-block:: nim - let v = 3 + let a = 3 AST: From b168efd1ab06422d147b1938aed6e0ed19e6134f Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Mon, 8 Jan 2018 13:43:43 +0100 Subject: [PATCH 3/5] make strformat.fmt take the same signature as strfmt.fmt in order to force an ambiguity error; refs #6958 --- lib/pure/strformat.nim | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/pure/strformat.nim b/lib/pure/strformat.nim index 180cbcbecc..e04c80794b 100644 --- a/lib/pure/strformat.nim +++ b/lib/pure/strformat.nim @@ -224,7 +224,7 @@ template callFormatOption(res, arg, option) {.dirty.} = else: res.add format(arg, option) -macro fmt*(pattern: string): untyped = +macro fmt*(pattern: string{lit}): untyped = ## For a specification of the ``fmt`` macro, see the module level documentation. runnableExamples: template check(actual, expected: string) = @@ -332,7 +332,7 @@ macro fmt*(pattern: string): untyped = # works: import times - var nullTime: TimeInfo + var nullTime: DateTime check fmt"{nullTime:yyyy-mm-dd}", "0000-00-00" # Unicode string tests @@ -609,7 +609,6 @@ proc format*(value: string; specifier: string; res: var string) = ## sense to call this directly, but it is required to exist ## by the ``fmt`` macro. let spec = parseStandardFormatSpecifier(specifier) - var fmode = ffDefault case spec.typ of 's', '\0': discard else: From ceb8ba49576ed0f27cf6ec031369c42ddf68757d Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Mon, 8 Jan 2018 18:02:38 +0100 Subject: [PATCH 4/5] fixes #7018 --- compiler/semexprs.nim | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index 51e75e91fb..f4f691889e 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -1865,17 +1865,16 @@ proc semMagic(c: PContext, n: PNode, s: PSym, flags: TExprFlags): PNode = result = magicsAfterOverloadResolution(c, result, flags) of mRunnableExamples: if gCmd == cmdDoc and n.len >= 2 and n.lastSon.kind == nkStmtList: - if n.sons[0].kind == nkIdent: - if sfMainModule in c.module.flags: - let inp = toFullPath(c.module.info) - if c.runnableExamples == nil: - c.runnableExamples = newTree(nkStmtList, - newTree(nkImportStmt, newStrNode(nkStrLit, expandFilename(inp)))) - let imports = newTree(nkStmtList) - extractImports(n.lastSon, imports) - for imp in imports: c.runnableExamples.add imp - c.runnableExamples.add newTree(nkBlockStmt, emptyNode, copyTree n.lastSon) - result = setMs(n, s) + if sfMainModule in c.module.flags: + let inp = toFullPath(c.module.info) + if c.runnableExamples == nil: + c.runnableExamples = newTree(nkStmtList, + newTree(nkImportStmt, newStrNode(nkStrLit, expandFilename(inp)))) + let imports = newTree(nkStmtList) + extractImports(n.lastSon, imports) + for imp in imports: c.runnableExamples.add imp + c.runnableExamples.add newTree(nkBlockStmt, emptyNode, copyTree n.lastSon) + result = setMs(n, s) else: result = emptyNode else: From c924fac5c889c5eace083707e62c60f16544573b Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Mon, 8 Jan 2018 18:22:18 +0100 Subject: [PATCH 5/5] fixes #7019 --- compiler/renderer.nim | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/compiler/renderer.nim b/compiler/renderer.nim index 6735cc1ce2..c45de0db9c 100644 --- a/compiler/renderer.nim +++ b/compiler/renderer.nim @@ -898,6 +898,14 @@ proc gsub(g: var TSrcGen, n: PNode, c: TContext) = put(g, tkBracketLe, "[") gcomma(g, n, 2) put(g, tkBracketRi, "]") + elif n.len > 1 and n.lastSon.kind == nkStmtList: + gsub(g, n[0]) + if n.len > 2: + put(g, tkParLe, "(") + gcomma(g, n, 1, -2) + put(g, tkParRi, ")") + put(g, tkColon, ":") + gsub(g, n, n.len-1) else: if sonsLen(n) >= 1: gsub(g, n.sons[0]) put(g, tkParLe, "(")