diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2020-06-23 10:53:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-23 10:53:57 +0200 |
commit | da29222f86f7689227ffe12605842d18c9bf0fc1 (patch) | |
tree | 312152d96e2313a81170c772ff7b51475299f344 /lib/core | |
parent | a9eee6db65e72e0e11cbf5faf0794b1b6ac8bd0c (diff) | |
download | Nim-da29222f86f7689227ffe12605842d18c9bf0fc1.tar.gz |
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
Diffstat (limited to 'lib/core')
-rw-r--r-- | lib/core/macros.nim | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/core/macros.nim b/lib/core/macros.nim index 1b0986d33..5be3a2cce 100644 --- a/lib/core/macros.nim +++ b/lib/core/macros.nim @@ -535,9 +535,7 @@ proc copyLineInfo*(arg: NimNode, info: NimNode) {.magic: "NLineInfo", noSideEffe proc lineInfoObj*(n: NimNode): LineInfo {.compileTime.} = ## Returns ``LineInfo`` of ``n``, using absolute path for ``filename``. - result.filename = n.getFile - result.line = n.getLine - result.column = n.getColumn + result = LineInfo(filename: n.getFile, line: n.getLine, column: n.getColumn) proc lineInfo*(arg: NimNode): string {.compileTime.} = ## Return line info in the form `filepath(line, column)`. @@ -878,12 +876,14 @@ proc treeRepr*(n: NimNode): string {.compileTime, benign.} = ## Convert the AST `n` to a human-readable tree-like string. ## ## See also `repr`, `lispRepr`, and `astGenRepr`. + result = "" n.treeTraverse(result, isLisp = false, indented = true) proc lispRepr*(n: NimNode; indented = false): string {.compileTime, benign.} = ## Convert the AST ``n`` to a human-readable lisp-like string. ## ## See also ``repr``, ``treeRepr``, and ``astGenRepr``. + result = "" n.treeTraverse(result, isLisp = true, indented = indented) proc astGenRepr*(n: NimNode): string {.compileTime, benign.} = @@ -1611,6 +1611,7 @@ macro getCustomPragmaVal*(n: typed, cp: typed{nkSym}): untyped = ## assert(o.myField.getCustomPragmaVal(serializationKey) == "mf") ## assert(o.getCustomPragmaVal(serializationKey) == "mo") ## assert(MyObj.getCustomPragmaVal(serializationKey) == "mo") + result = nil let pragmaNode = customPragmaNode(n) for p in pragmaNode: if p.kind in nnkPragmaCallKinds and p.len > 0 and p[0].kind == nnkSym and p[0] == cp: |