remove conditionals on nimHasUserErrors, nimNoNilSeqs2, nimNoNilSeqs (#16861)
* cleanup docs for type(nil) | type(nil); simplify nimHasUserErrors * simplify nimNoNilSeqs2 * simplify nimNoNilSeqs * fixup
This commit is contained in:
parent
4e1e231e29
commit
6e267d28b3
13 changed files with 29 additions and 93 deletions
|
|
@ -1559,11 +1559,8 @@ proc len*[U: Ordinal; V: Ordinal](x: HSlice[U, V]): int {.noSideEffect, inline.}
|
|||
## assert((5..2).len == 0)
|
||||
result = max(0, ord(x.b) - ord(x.a) + 1)
|
||||
|
||||
when defined(nimNoNilSeqs2):
|
||||
when not compileOption("nilseqs"):
|
||||
{.pragma: nilError, error.}
|
||||
else:
|
||||
{.pragma: nilError.}
|
||||
when not compileOption("nilseqs"):
|
||||
{.pragma: nilError, error.}
|
||||
else:
|
||||
{.pragma: nilError.}
|
||||
|
||||
|
|
@ -2942,19 +2939,16 @@ proc `==`*(x, y: cstring): bool {.magic: "EqCString", noSideEffect,
|
|||
elif x.isNil or y.isNil: result = false
|
||||
else: result = strcmp(x, y) == 0
|
||||
|
||||
when defined(nimNoNilSeqs2) and not compileOption("nilseqs"):
|
||||
when defined(nimHasUserErrors):
|
||||
# bug #9149; ensure that 'type(nil)' does not match *too* well by using 'type(nil) | type(nil)'.
|
||||
# Eventually (in 0.20?) we will be able to remove this hack completely.
|
||||
proc `==`*(x: string; y: type(nil) | type(nil)): bool {.
|
||||
error: "'nil' is now invalid for 'string'; compile with --nilseqs:on for a migration period".} =
|
||||
discard
|
||||
proc `==`*(x: type(nil) | type(nil); y: string): bool {.
|
||||
error: "'nil' is now invalid for 'string'; compile with --nilseqs:on for a migration period".} =
|
||||
discard
|
||||
else:
|
||||
proc `==`*(x: string; y: type(nil) | type(nil)): bool {.error.} = discard
|
||||
proc `==`*(x: type(nil) | type(nil); y: string): bool {.error.} = discard
|
||||
when not compileOption("nilseqs"):
|
||||
# bug #9149; ensure that 'type(nil)' does not match *too* well by using 'type(nil) | type(nil)',
|
||||
# especially for converters, see tests/overload/tconverter_to_string.nim
|
||||
# Eventually we will be able to remove this hack completely.
|
||||
proc `==`*(x: string; y: type(nil) | type(nil)): bool {.
|
||||
error: "'nil' is now invalid for 'string'; compile with --nilseqs:on for a migration period".} =
|
||||
discard
|
||||
proc `==`*(x: type(nil) | type(nil); y: string): bool {.
|
||||
error: "'nil' is now invalid for 'string'; compile with --nilseqs:on for a migration period".} =
|
||||
discard
|
||||
|
||||
template closureScope*(body: untyped): untyped =
|
||||
## Useful when creating a closure in a loop to capture local loop variables by
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue