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
ass='oid'>e25474154 ^
a9ef5bf45 ^
ff914b89d ^
bcdb5b083 ^


a9ef5bf45 ^
ff914b89d ^
bcdb5b083 ^

a9ef5bf45 ^
80ee28daf ^





dae545094 ^
80ee28daf ^


a9ef5bf45 ^
ff914b89d ^
bcdb5b083 ^
80ee28daf ^
a9ef5bf45 ^
ff914b89d ^
bcdb5b083 ^
80ee28daf ^
a9ef5bf45 ^
ff914b89d ^
7e747d11c ^
80ee28daf ^
a9ef5bf45 ^
ff914b89d ^
80ee28daf ^

a9ef5bf45 ^
ff914b89d ^
80ee28daf ^

ff914b89d ^





f89218c8b ^

ff914b89d ^


ff914b89d ^









e25474154 ^
86556ebfd ^
2f43fdb83 ^
86556ebfd ^
92b8fac94 ^
e25474154 ^
b2c7910fb ^
869a5aa90 ^
b2c7910fb ^
e25474154 ^
ff914b89d ^



7e747d11c ^
ff914b89d ^


7e747d11c ^
ff914b89d ^



abb05ab64 ^
064417fc5 ^
e25474154 ^
064417fc5 ^
7e747d11c ^
a541be893 ^
e25474154 ^

a541be893 ^
7e747d11c ^
e25474154 ^
a541be893 ^
e25474154 ^
7e747d11c ^
e25474154 ^
a541be893 ^
064417fc5 ^
a541be893 ^
91f42a294 ^
e25474154 ^
7e0540ed8 ^
e25474154 ^
d0edb1826 ^
b2c7910fb ^
b0c11d3ef ^
7e747d11c ^
aafbe5c86 ^


0f131b9f4 ^
aafbe5c86 ^


0f131b9f4 ^
b2c7910fb ^

aafbe5c86 ^

b2c7910fb ^
aafbe5c86 ^
7e747d11c ^
0b197ade6 ^
7e747d11c ^
91f42a294 ^
fe750a5cf ^
7e747d11c ^
e25474154 ^
d0edb1826 ^
b2c7910fb ^
064417fc5 ^
7e747d11c ^
fe750a5cf ^

a541be893 ^
7e747d11c ^
438703f59 ^
e25474154 ^
abb05ab64 ^



ff914b89d ^
7e747d11c ^
91f42a294 ^
027f30610 ^
39049e151 ^
027f30610 ^

a9ef5bf45 ^
027f30610 ^

39049e151 ^
027f30610 ^

f644e3079 ^
a541be893 ^
e25474154 ^

ff914b89d ^

d68181246 ^
ff914b89d ^


ff3cf001a ^

ff914b89d ^


7e747d11c ^

171996465 ^



ff3cf001a ^
171996465 ^


7e747d11c ^
ff914b89d ^

171996465 ^

ff914b89d ^
171996465 ^
171996465 ^
ff3cf001a ^

171996465 ^
86556ebfd ^
ff914b89d ^

171996465 ^
86556ebfd ^
a541be893 ^
171996465 ^

e25474154 ^
86556ebfd ^
e25474154 ^
171996465 ^
b2c7910fb ^
a541be893 ^
e25474154 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338