fix #16025 repr now consistent: does not insert trailing newline (#16034)

This commit is contained in:
Timothee Cour 2020-11-19 12:12:51 -08:00 • committed by GitHub
commit b3c3557c33
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 105 additions and 84 deletions

View file

@ -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.