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
This commit is contained in:
ringabout 2022-10-15 20:07:40 +08:00 • committed by GitHub
commit 1e15f975b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 38 additions and 39 deletions

View file

@ -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, "[", ", ", "]")