diff options
author | Timothee Cour <timothee.cour2@gmail.com> | 2020-11-19 12:12:51 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-19 12:12:51 -0800 |
commit | b3c3557c338c6cb0992abf9d2d877e927d815ea3 (patch) | |
tree | 4d4f0754eaa2c0b84db7c4d8bcc21e60bfb4a845 /lib | |
parent | 1efd11e2666403fecf1b9b3b933c1adca13d8069 (diff) | |
download | Nim-b3c3557c338c6cb0992abf9d2d877e927d815ea3.tar.gz |
fix #16025 repr now consistent: does not insert trailing newline (#16034)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/system.nim | 3 | ||||
-rw-r--r-- | lib/system/repr.nim | 3 | ||||
-rw-r--r-- | lib/system/reprjs.nim | 3 |
3 files changed, 7 insertions, 2 deletions
diff --git a/lib/system.nim b/lib/system.nim index 1104cb17f..716eb296a 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -1334,6 +1334,9 @@ proc insert*[T](x: var seq[T], item: sink T, i = 0.Natural) {.noSideEffect.} = when not defined(nimV2): proc repr*[T](x: T): string {.magic: "Repr", noSideEffect.} ## Takes any Nim variable and returns its string representation. + ## No trailing newline is inserted (so `echo` won't add an empty newline). + ## Use `-d:nimLegacyReprWithNewline` to revert to old behavior where newlines + ## were added in some cases. ## ## It works even for complex data graphs with cycles. This is a great ## debugging tool. diff --git a/lib/system/repr.nim b/lib/system/repr.nim index 318e95ebb..ae51a4aab 100644 --- a/lib/system/repr.nim +++ b/lib/system/repr.nim @@ -325,5 +325,6 @@ when not defined(useNimRtl): else: var p = p reprAux(result, addr(p), typ, cl) - add result, "\n" + when defined(nimLegacyReprWithNewline): # see PR #16034 + add result, "\n" deinitReprClosure(cl) diff --git a/lib/system/reprjs.nim b/lib/system/reprjs.nim index 9c27a4721..36972024a 100644 --- a/lib/system/reprjs.nim +++ b/lib/system/reprjs.nim @@ -237,4 +237,5 @@ proc reprAny(p: pointer, typ: PNimType): string {.compilerRtl.} = var cl: ReprClosure initReprClosure(cl) reprAux(result, p, typ, cl) - add(result, "\n") + when defined(nimLegacyReprWithNewline): # see PR #16034 + add result, "\n" |