mirror of
https://github.com/nim-lang/Nim.git
synced 2026-08-30 18:41:45 +00:00
strictdefs for repr so that it can used for debugging purposes in t… (#23501)
…he compiler
This commit is contained in:
@@ -41,7 +41,7 @@ proc repr*(x: char): string {.noSideEffect, raises: [].} =
|
||||
## ```Nim
|
||||
## assert repr('c') == "'c'"
|
||||
## ```
|
||||
result.add '\''
|
||||
result = "'"
|
||||
# Elides string creations if not needed
|
||||
if x in {'\\', '\0'..'\31', '\127'..'\255'}:
|
||||
result.add '\\'
|
||||
@@ -54,7 +54,7 @@ proc repr*(x: char): string {.noSideEffect, raises: [].} =
|
||||
proc repr*(x: string | cstring): string {.noSideEffect, raises: [].} =
|
||||
## repr for a string argument. Returns `x`
|
||||
## converted to a quoted and escaped string.
|
||||
result.add '\"'
|
||||
result = "\""
|
||||
for i in 0..<x.len:
|
||||
if x[i] in {'"', '\\', '\0'..'\31', '\127'..'\255'}:
|
||||
result.add '\\'
|
||||
|
||||
Reference in New Issue
Block a user