From de263a43c615199f66440d8d27fe4fb7da3435e3 Mon Sep 17 00:00:00 2001 From: Araq Date: Wed, 8 Aug 2018 11:21:56 +0200 Subject: deprecate isNil for strings and seqs --- lib/system.nim | 8 ++++---- tests/system/tnilconcats.nim | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/system.nim b/lib/system.nim index 53605f9fd..3a82299ac 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -2321,9 +2321,9 @@ iterator mpairs*(a: var cstring): tuple[key: int, val: var char] {.inline.} = inc(i) -proc isNil*[T](x: seq[T]): bool {.noSideEffect, magic: "IsNil".} +proc isNil*[T](x: seq[T]): bool {.noSideEffect, magic: "IsNil", deprecated.} proc isNil*[T](x: ref T): bool {.noSideEffect, magic: "IsNil".} -proc isNil*(x: string): bool {.noSideEffect, magic: "IsNil".} +proc isNil*(x: string): bool {.noSideEffect, magic: "IsNil", deprecated.} proc isNil*[T](x: ptr T): bool {.noSideEffect, magic: "IsNil".} proc isNil*(x: pointer): bool {.noSideEffect, magic: "IsNil".} proc isNil*(x: cstring): bool {.noSideEffect, magic: "IsNil".} @@ -2520,7 +2520,7 @@ proc `$`*[T: tuple|object](x: T): string = result.add(name) result.add(": ") when compiles($value): - when compiles(value.isNil): + when value isnot string and value isnot seq and compiles(value.isNil): if value.isNil: result.add "nil" else: result.addQuoted(value) else: @@ -2539,7 +2539,7 @@ proc collectionToString[T](x: T, prefix, separator, suffix: string): string = else: result.add(separator) - when compiles(value.isNil): + when value isnot string and value isnot seq and compiles(value.isNil): # this branch should not be necessary if value.isNil: result.add "nil" diff --git a/tests/system/tnilconcats.nim b/tests/system/tnilconcats.nim index ce059b7b0..5e4a1b317 100644 --- a/tests/system/tnilconcats.nim +++ b/tests/system/tnilconcats.nim @@ -1,5 +1,5 @@ discard """ - output: '''@[nil, nil, nil, nil, nil, nil, nil, "meh"]''' + output: '''@["", "", "", "", "", "", "", "meh"]''' exitcode: "0" """ -- cgit 1.4.1-2-gfad0 '>range
path: root/start.bat
blob: 7328211ca5c5808c7c360d724f1f6a483656669b (plain) (tree)
1
2
3
4
5
6