diff options
author | ringabout <43030857+ringabout@users.noreply.github.com> | 2022-10-15 20:07:40 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-15 14:07:40 +0200 |
commit | 1e15f975b83951006d69e6e39836aa2d525028c4 (patch) | |
tree | d43b2b539494a46df310d91d565c9858e6dcb0b9 /lib/system/repr_v2.nim | |
parent | 0510a2be0d6df674aa91ae3f2884d98473cade4c (diff) | |
download | Nim-1e15f975b83951006d69e6e39836aa2d525028c4.tar.gz |
fixes #19162; enable `strictEffects` for v2 (#19380)
* enable stricteffects * add gcsafe * fix tests * use func * fixes pegs tests * explicitly mark repr related procs with noSideEffect * add nimLegacyEffects * change URL * fixes docopt * add `raises: []` to repr * fixes weave * fixes nimyaml * fixes glob * fixes parsetoml * Apply suggestions from code review * Update testament/important_packages.nim * add legacy:laxEffects
Diffstat (limited to 'lib/system/repr_v2.nim')
-rw-r--r-- | lib/system/repr_v2.nim | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/system/repr_v2.nim b/lib/system/repr_v2.nim index 0e9bec0f3..60c09e073 100644 --- a/lib/system/repr_v2.nim +++ b/lib/system/repr_v2.nim @@ -31,7 +31,7 @@ proc repr*(x: bool): string {.magic: "BoolToStr", noSideEffect.} ## repr for a boolean argument. Returns `x` ## converted to the string "false" or "true". -proc repr*(x: char): string {.noSideEffect.} = +proc repr*(x: char): string {.noSideEffect, raises: [].} = ## repr for a character argument. Returns `x` ## converted to an escaped string. ## @@ -47,7 +47,7 @@ proc repr*(x: char): string {.noSideEffect.} = result.add x result.add '\'' -proc repr*(x: string | cstring): string {.noSideEffect.} = +proc repr*(x: string | cstring): string {.noSideEffect, raises: [].} = ## repr for a string argument. Returns `x` ## converted to a quoted and escaped string. result.add '\"' @@ -63,7 +63,7 @@ proc repr*(x: string | cstring): string {.noSideEffect.} = result.add x[i] result.add '\"' -proc repr*[Enum: enum](x: Enum): string {.magic: "EnumToStr", noSideEffect.} +proc repr*[Enum: enum](x: Enum): string {.magic: "EnumToStr", noSideEffect, raises: [].} ## repr for an enumeration argument. This works for ## any enumeration type thanks to compiler magic. ## @@ -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, raises: [].} = res.add '(' var firstElement = true const isNamed = T is object or isNamedTuple(T) @@ -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, raises: [].} = ## Generic `repr` operator for tuples that is lifted from the components ## of `x`. Example: ## @@ -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, raises: [].} = if isNil(x): return "nil" when T is object: result = $typeof(x) @@ -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, raises: [].} = result = prefix var firstElement = true for value in items(x): @@ -189,4 +189,4 @@ proc repr*[T](x: openArray[T]): string = ## ## .. code-block:: Nim ## $(@[23, 45].toOpenArray(0, 1)) == "[23, 45]" - collectionToRepr(x, "[", ", ", "]") + collectionToRepr(x, "[", ", ", "]") \ No newline at end of file |