summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2019-06-05 08:02:54 +0200
committerGitHub <noreply@github.com>2019-06-05 08:02:54 +0200
commit721534119000c2bd53cc72b531726a6104381222 (patch)
treeb03f8b734bfd4526ce719cd065e94d0f8e34a171
parentfc4f0808c45ab8e72e2c2e3792e4756d9380fe8c (diff)
downloadNim-721534119000c2bd53cc72b531726a6104381222.tar.gz
make fullpaths the default in error messages and stack traces for mor… (#11385)
* make fullpaths the default in error messages and stack traces for more convenient development
* split up -d:release into -d:release and -d:danger flags
* workaround a Nim config parser bug
* fixes an old nim config parser bug
* make megatest green again
* make nimpretty tests work again
* make nimsuggest green
-rw-r--r--changelog.md4
-rw-r--r--compiler/lambdalifting.nim4
-rw-r--r--compiler/main.nim3
-rw-r--r--compiler/nimconf.nim6
-rw-r--r--compiler/options.nim7
-rw-r--r--compiler/vm.nim2
-rw-r--r--config/nim.cfg23
-rw-r--r--koch.nim6
-rw-r--r--lib/pure/collections/tableimpl.nim2
-rw-r--r--lib/pure/collections/tables.nim2
-rw-r--r--nimpretty/nimpretty.nim.cfg1
-rw-r--r--nimsuggest/nimsuggest.nim.cfg1
-rw-r--r--testament/categories.nim3
-rw-r--r--tests/overflw/toverflw.nim2
-rw-r--r--tests/vm/tcompiletimerange.nim2
15 files changed, 41 insertions, 27 deletions
diff --git a/changelog.md b/changelog.md
index e16211a3d..f75958a73 100644
--- a/changelog.md
+++ b/changelog.md
@@ -277,7 +277,9 @@ proc enumToString*(enums: openArray[enum]): string =
   hot code reloading events in the code.
 - The compiler nows supports a ``--expandMacro:macroNameHere`` switch
   for easy introspection into what a macro expands into.
-
+- The `-d:release` switch now does not disable runtime checks anymore.
+  For a release build that also disables runtime checks
+  use `-d:release -d:danger` or simply `-d:danger`.
 
 
 ### Bugfixes
diff --git a/compiler/lambdalifting.nim b/compiler/lambdalifting.nim
index 6f0f8e0a5..e2d1a143f 100644
--- a/compiler/lambdalifting.nim
+++ b/compiler/lambdalifting.nim
@@ -480,9 +480,7 @@ proc detectCapturedVars(n: PNode; owner: PSym; c: var DetectionPass) =
     if n.typ != nil:
       detectCapturedVars(n[namePos], owner, c)
   of nkReturnStmt:
-    if n[0].kind in {nkAsgn, nkFastAsgn}:
-      detectCapturedVars(n[0].sons[1], owner, c)
-    else: assert n[0].kind == nkEmpty
+    detectCapturedVars(n[0], owner, c)
   else:
     for i in 0..<n.len:
       detectCapturedVars(n[i], owner, c)
diff --git a/compiler/main.nim b/compiler/main.nim
index 84a0fb97d..acd7c7485 100644
--- a/compiler/main.nim
+++ b/compiler/main.nim
@@ -363,7 +363,8 @@ proc mainCommand*(graph: ModuleGraph) =
     rawMessage(conf, hintSuccessX, [$conf.linesCompiled,
                formatFloat(epochTime() - conf.lastCmdTime, ffDecimal, 3),
                usedMem,
-               if isDefined(conf, "release"): "Release Build"
+               if isDefined(conf, "danger"): "Dangerous Release Build"
+               elif isDefined(conf, "release"): "Release Build"
                else: "Debug Build"])
 
   when PrintRopeCacheStats:
diff --git a/compiler/nimconf.nim b/compiler/nimconf.nim
index c0aeab7e3..02d1e7d2a 100644
--- a/compiler/nimconf.nim
+++ b/compiler/nimconf.nim
@@ -28,7 +28,7 @@ proc parseAtom(L: var TLexer, tok: var TToken; config: ConfigRef): bool =
     result = parseExpr(L, tok, config)
     if tok.tokType == tkParRi: ppGetTok(L, tok)
     else: lexMessage(L, errGenerated, "expected closing ')'")
-  elif tok.ident.id == ord(wNot):
+  elif tok.tokType == tkNot:
     ppGetTok(L, tok)
     result = not parseAtom(L, tok, config)
   else:
@@ -37,14 +37,14 @@ proc parseAtom(L: var TLexer, tok: var TToken; config: ConfigRef): bool =
 
 proc parseAndExpr(L: var TLexer, tok: var TToken; config: ConfigRef): bool =
   result = parseAtom(L, tok, config)
-  while tok.ident.id == ord(wAnd):
+  while tok.tokType == tkAnd:
     ppGetTok(L, tok)          # skip "and"
     var b = parseAtom(L, tok, config)
     result = result and b
 
 proc parseExpr(L: var TLexer, tok: var TToken; config: ConfigRef): bool =
   result = parseAndExpr(L, tok, config)
-  while tok.ident.id == ord(wOr):
+  while tok.tokType == tkOr:
     ppGetTok(L, tok)          # skip "or"
     var b = parseAndExpr(L, tok, config)
     result = result or b
diff --git a/compiler/options.nim b/compiler/options.nim
index 833af6846..ee0697600 100644
--- a/compiler/options.nim
+++ b/compiler/options.nim
@@ -276,7 +276,8 @@ const
     optBoundsCheck, optOverflowCheck, optAssert, optWarns,
     optHints, optStackTrace, optLineTrace,
     optTrMacros, optNilCheck, optMoveCheck}
-  DefaultGlobalOptions* = {optThreadAnalysis}
+  DefaultGlobalOptions* = {optThreadAnalysis,
+    optExcessiveStackTrace, optListFullPaths}
 
 proc getSrcTimestamp(): DateTime =
   try:
@@ -312,7 +313,7 @@ proc newConfigRef*(): ConfigRef =
     macrosToExpand: newStringTable(modeStyleInsensitive),
     m: initMsgConfig(),
     evalExpr: "",
-    cppDefines: initSet[string](),
+    cppDefines: initHashSet[string](),
     headerFile: "", features: {}, foreignPackageNotes: {hintProcessing, warnUnknownMagic,
     hintQuitCalled, hintExecuting},
     notes: NotesVerbosity[1], mainPackageNotes: NotesVerbosity[1],
@@ -540,7 +541,7 @@ proc getNimcacheDir*(conf: ConfigRef): AbsoluteDir =
              conf.projectPath / genSubDir
            else:
             AbsoluteDir(getOsCacheDir() / splitFile(conf.projectName).name &
-               (if isDefined(conf, "release"): "_r" else: "_d"))
+               (if isDefined(conf, "release") or isDefined(conf, "danger"): "_r" else: "_d"))
 
 proc pathSubs*(conf: ConfigRef; p, config: string): string =
   let home = removeTrailingDirSep(os.getHomeDir())
diff --git a/compiler/vm.nim b/compiler/vm.nim
index 884500be8..f2d989a8d 100644
--- a/compiler/vm.nim
+++ b/compiler/vm.nim
@@ -1189,7 +1189,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
     of opcFinallyEnd:
       # The control flow may not resume at the next instruction since we may be
       # raising an exception or performing a cleanup.
-      if not savedPC < 0:
+      if savedPC >= 0:
         pc = savedPC - 1
         savedPC = -1
         if tos != savedFrame:
diff --git a/config/nim.cfg b/config/nim.cfg
index db0336f89..89906a47d 100644
--- a/config/nim.cfg
+++ b/config/nim.cfg
@@ -52,7 +52,7 @@ path="$lib/pure"
   @end
 @end
 
-@if release or quick:
+@if danger or quick:
   obj_checks:off
   field_checks:off
   range_checks:off
@@ -69,10 +69,19 @@ path="$lib/pure"
   @end
 @end
 
-@if release:
+@if release or danger:
+  stacktrace:off
+  linetrace:off
+  debugger:off
+  line_dir:off
   opt:speed
 @end
 
+@if false: # not danger: # this does not work yet.
+  clang.options.always %= "${clang.options.always} -fsanitize=null -fsanitize-undefined-trap-on-error"
+  gcc.options.always %= "${gcc.options.always} -fsanitize=null -fsanitize-undefined-trap-on-error"
+@end
+
 @if unix and mingw:
   # Cross compile for Windows from Linux/OSX using MinGW
   os = windows
@@ -200,13 +209,13 @@ clang.objc.options.linker = "-lobjc -lgnustep-base"
 gcc.options.speed = "-O3 -fno-strict-aliasing"
 gcc.options.size = "-Os"
 @if windows:
-  gcc.options.debug = "-g3 -O0 -gdwarf-3"
+  gcc.options.debug = "-g3 -Og -gdwarf-3"
 @else:
-  gcc.options.debug = "-g3 -O0"
+  gcc.options.debug = "-g3 -Og"
 @end
 gcc.cpp.options.speed = "-O3 -fno-strict-aliasing"
 gcc.cpp.options.size = "-Os"
-gcc.cpp.options.debug = "-g3 -O0"
+gcc.cpp.options.debug = "-g3 -Og"
 #passl = "-pg"
 
 # Configuration for the LLVM GCC compiler:
@@ -224,13 +233,13 @@ clang.options.size = "-Os"
 
 @if windows:
   clang_cl.cpp.options.always %= "${clang_cl.options.always} /EHsc"
-  @if not release:
+  @if not release and not safety and not danger:
     clang_cl.options.linker = "/Z7"
     clang_cl.cpp.options.linker = "/Z7"
   @end
   clang.options.debug = "-g -gcodeview"
   clang.cpp.options.debug = "-g -gcodeview"
-  @if not release:
+  @if not release and not safety and not danger:
     clang.options.linker = "-g"
     clang.cpp.options.linker = "-g"
   @end
diff --git a/koch.nim b/koch.nim
index 8313d0866..1832a49b9 100644
--- a/koch.nim
+++ b/koch.nim
@@ -165,7 +165,7 @@ proc buildNimble(latest: bool) =
   nimCompile(installDir / "src/nimble.nim", options = "--noNimblePath --nilseqs:on -d:release")
 
 proc bundleNimsuggest() =
-  nimCompileFold("Compile nimsuggest", "nimsuggest/nimsuggest.nim", options = "-d:release")
+  nimCompileFold("Compile nimsuggest", "nimsuggest/nimsuggest.nim", options = "-d:release -d:danger")
 
 proc buildVccTool() =
   nimCompileFold("Compile Vcc", "tools/vccexe/vccexe.nim")
@@ -286,7 +286,7 @@ proc boot(args: string) =
   var finalDest = "bin" / "nim".exe
   # default to use the 'c' command:
   let useCpp = getEnv("NIM_COMPILE_TO_CPP", "false") == "true"
-  let smartNimcache = (if "release" in args: "nimcache/r_" else: "nimcache/d_") &
+  let smartNimcache = (if "release" in args or "danger" in args: "nimcache/r_" else: "nimcache/d_") &
                       hostOs & "_" & hostCpu
 
   let nimStart = findStartNim()
@@ -463,7 +463,7 @@ proc runCI(cmd: string) =
   when defined(posix): # appveyor (on windows) didn't run this
     kochExecFold("Boot", "boot")
   # boot without -d:nimHasLibFFI to make sure this still works
-  kochExecFold("Boot in release mode", "boot -d:release")
+  kochExecFold("Boot in release mode", "boot -d:release -d:danger")
 
   ## build nimble early on to enable remainder to depend on it if needed
   kochExecFold("Build Nimble", "nimble")
diff --git a/lib/pure/collections/tableimpl.nim b/lib/pure/collections/tableimpl.nim
index 4f9610db3..ad9445c91 100644
--- a/lib/pure/collections/tableimpl.nim
+++ b/lib/pure/collections/tableimpl.nim
@@ -149,7 +149,7 @@ template dollarImpl(): untyped {.dirty.} =
       result.addQuoted(val)
     result.add("}")
 
-template equalsImpl(s, t: typed): typed =
+template equalsImpl(s, t: typed) =
   if s.counter == t.counter:
     # different insertion orders mean different 'data' seqs, so we have
     # to use the slow route here:
diff --git a/lib/pure/collections/tables.nim b/lib/pure/collections/tables.nim
index 84284edb3..bf1f3c692 100644
--- a/lib/pure/collections/tables.nim
+++ b/lib/pure/collections/tables.nim
@@ -1252,7 +1252,7 @@ proc enlarge[A, B](t: var OrderedTable[A, B]) =
       rawInsert(t, t.data, n[h].key, n[h].val, n[h].hcode, j)
     h = nxt
 
-template forAllOrderedPairs(yieldStmt: untyped): typed {.dirty.} =
+template forAllOrderedPairs(yieldStmt: untyped) {.dirty.} =
   var h = t.first
   while h >= 0:
     var nxt = t.data[h].next
diff --git a/nimpretty/nimpretty.nim.cfg b/nimpretty/nimpretty.nim.cfg
index 5fafa6d2a..9eb185370 100644
--- a/nimpretty/nimpretty.nim.cfg
+++ b/nimpretty/nimpretty.nim.cfg
@@ -1,2 +1,3 @@
 --define: nimpretty
 --define: nimpretty2
+-define: nimOldCaseObjects
diff --git a/nimsuggest/nimsuggest.nim.cfg b/nimsuggest/nimsuggest.nim.cfg
index 394449740..302c30965 100644
--- a/nimsuggest/nimsuggest.nim.cfg
+++ b/nimsuggest/nimsuggest.nim.cfg
@@ -22,3 +22,4 @@ define:nimcore
 #define:noDocgen
 --path:"$nim"
 --threads:on
+--define:nimOldCaseObjects
diff --git a/testament/categories.nim b/testament/categories.nim
index c5769347a..4fddeb554 100644
--- a/testament/categories.nim
+++ b/testament/categories.nim
@@ -647,7 +647,8 @@ proc runJoinedTest(r: var TResults, cat: Category, testsDir: string) =
 
   writeFile("megatest.nim", megatest)
 
-  let args = ["c", "--nimCache:" & outDir, "-d:testing", "--listCmd", "megatest.nim"]
+  let args = ["c", "--nimCache:" & outDir, "-d:testing", "--listCmd",
+              "--listFullPaths:off", "--excessiveStackTrace:off", "megatest.nim"]
   proc onStdout(line: string) = echo line
   var (cmdLine, buf, exitCode) = execCmdEx2(command = compilerPrefix, args = args, input = "")
   if exitCode != 0:
diff --git a/tests/overflw/toverflw.nim b/tests/overflw/toverflw.nim
index aef597e6c..d96231900 100644
--- a/tests/overflw/toverflw.nim
+++ b/tests/overflw/toverflw.nim
@@ -1,6 +1,6 @@
 discard """
   output: "ok"
-  cmd: "nim $target -d:release $options $file"
+  cmd: "nim $target --overflowChecks:off $options $file"
 """
 # Tests nim's ability to detect overflows
 
diff --git a/tests/vm/tcompiletimerange.nim b/tests/vm/tcompiletimerange.nim
index fd809985e..f2eb1b75b 100644
--- a/tests/vm/tcompiletimerange.nim
+++ b/tests/vm/tcompiletimerange.nim
@@ -4,7 +4,7 @@ const rangesGCHoldEnabled = not defined(rangesDisableGCHold)
 
 type
   # A view into immutable array
-  Range* {.shallow.} [T] = object
+  Range*[T] {.shallow.} = object
     when rangesGCHoldEnabled:
       gcHold: seq[T]
     start: ptr T