init checks and 'out' parameters (#14521)

* I don't care about observable stores
* enforce explicit initializations
* cleaner code for the stdlib
* stdlib: use explicit initializations
* make tests green
* algorithm.nim: set result explicitly
* remove out parameters and bring the PR into a mergable state
* updated the changelog
This commit is contained in:
Andreas Rumpf
2020-06-23 10:53:57 +02:00
committed by GitHub
parent a9eee6db65
commit da29222f86
53 changed files with 355 additions and 257 deletions

View File

@@ -4,7 +4,7 @@ const NimStackTraceMsgs = compileOption("stacktraceMsgs")
template procName*(): string =
## returns current C/C++ function name
when defined(c) or defined(cpp):
var name {.inject.}: cstring
var name {.inject, noinit.}: cstring
{.emit: "`name` = __func__;".}
$name
@@ -12,7 +12,7 @@ template getPFrame*(): PFrame =
## avoids a function call (unlike `getFrame()`)
block:
when NimStackTrace:
var framePtr {.inject.}: PFrame
var framePtr {.inject, noinit.}: PFrame
{.emit: "`framePtr` = &FR_;".}
framePtr
@@ -21,7 +21,7 @@ template setFrameMsg*(msg: string, prefix = " ") =
## in a given PFrame. Noop unless passing --stacktraceMsgs and --stacktrace
when NimStackTrace and NimStackTraceMsgs:
block:
var fr {.inject.}: PFrame
var fr {.inject, noinit.}: PFrame
{.emit: "`fr` = &FR_;".}
# consider setting a custom upper limit on size (analog to stack overflow)
frameMsgBuf.setLen fr.frameMsgLen