* 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:
parent
0510a2be0d
commit
1e15f975b8
16 changed files with 38 additions and 39 deletions
|
|
@ -561,7 +561,7 @@ template matchOrParse(mopProc: untyped) =
|
|||
# procs. For the former, *enter* and *leave* event handler code generators
|
||||
# are provided which just return *discard*.
|
||||
|
||||
proc mopProc(s: string, p: Peg, start: int, c: var Captures): int =
|
||||
proc mopProc(s: string, p: Peg, start: int, c: var Captures): int {.gcsafe.} =
|
||||
proc matchBackRef(s: string, p: Peg, start: int, c: var Captures): int =
|
||||
# Parse handler code must run in an *of* clause of its own for each
|
||||
# *PegKind*, so we encapsulate the identical clause body for
|
||||
|
|
|
|||
|
|
@ -1701,7 +1701,7 @@ proc pop*[T](s: var seq[T]): T {.inline, noSideEffect.} =
|
|||
result = s[L]
|
||||
setLen(s, L)
|
||||
|
||||
proc `==`*[T: tuple|object](x, y: T): bool =
|
||||
func `==`*[T: tuple|object](x, y: T): bool =
|
||||
## Generic `==` operator for tuples that is lifted from the components.
|
||||
## of `x` and `y`.
|
||||
for a, b in fields(x, y):
|
||||
|
|
|
|||
|
|
@ -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, "[", ", ", "]")
|
||||
Loading…
Add table
Add a link
Reference in a new issue