Skip to content

Commit

Permalink
explicitly mark repr related procs with noSideEffect
Browse files Browse the repository at this point in the history
  • Loading branch information
ringabout committed Oct 7, 2022
1 parent 9fcbf62 commit 5842184
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/system/repr_v2.nim
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ template repr*(x: distinct): string =

template repr*(t: typedesc): string = $t

proc reprObject[T: tuple|object](res: var string, x: T) =
proc reprObject[T: tuple|object](res: var string, x: T) {.noSideEffect.} =
res.add '('
var firstElement = true
const isNamed = T is object or isNamedTuple(T)
Expand All @@ -121,7 +121,7 @@ proc reprObject[T: tuple|object](res: var string, x: T) =
res.add(')')


proc repr*[T: tuple|object](x: T): string =
proc repr*[T: tuple|object](x: T): string {.noSideEffect.} =
## Generic `repr` operator for tuples that is lifted from the components
## of `x`. Example:
##
Expand All @@ -133,7 +133,7 @@ proc repr*[T: tuple|object](x: T): string =
result = $typeof(x)
reprObject(result, x)

proc repr*[T](x: ref T | ptr T): string =
proc repr*[T](x: ref T | ptr T): string {.noSideEffect.} =
if isNil(x): return "nil"
when T is object:
result = $typeof(x)
Expand All @@ -142,7 +142,7 @@ proc repr*[T](x: ref T | ptr T): string =
result = when typeof(x) is ref: "ref " else: "ptr "
result.add repr(x[])

proc collectionToRepr[T](x: T, prefix, separator, suffix: string): string =
proc collectionToRepr[T](x: T, prefix, separator, suffix: string): string {.noSideEffect.} =
result = prefix
var firstElement = true
for value in items(x):
Expand Down

0 comments on commit 5842184

Please sign in to comment.