diff options
author | flywind <43030857+xflywind@users.noreply.github.com> | 2020-09-18 16:02:31 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-18 10:02:31 +0200 |
commit | c57023f3241e99910d44e91330a381e41193047f (patch) | |
tree | 47f0075381a430763f894cf3d3e9e89a6a01f388 | |
parent | cbd78ec1f68e78a88e4a83a5009bc4c8c28c79b3 (diff) | |
download | Nim-c57023f3241e99910d44e91330a381e41193047f.tar.gz |
string is not nil anymore (#15352)
-rw-r--r-- | lib/pure/collections/critbits.nim | 5 | ||||
-rw-r--r-- | lib/pure/strtabs.nim | 6 |
2 files changed, 3 insertions, 8 deletions
diff --git a/lib/pure/collections/critbits.nim b/lib/pure/collections/critbits.nim index 91c113988..d25e31d66 100644 --- a/lib/pure/collections/critbits.nim +++ b/lib/pure/collections/critbits.nim @@ -281,10 +281,7 @@ proc `[]=`*[T](c: var CritBitTree[T], key: string, val: T) = template get[T](c: CritBitTree[T], key: string): T = let n = rawGet(c, key) if n == nil: - when compiles($key): - raise newException(KeyError, "key not found: " & $key) - else: - raise newException(KeyError, "key not found") + raise newException(KeyError, "key not found: " & key) n.val diff --git a/lib/pure/strtabs.nim b/lib/pure/strtabs.nim index 864db148f..d9f6bbc54 100644 --- a/lib/pure/strtabs.nim +++ b/lib/pure/strtabs.nim @@ -141,10 +141,8 @@ template get(t: StringTableRef, key: string) = var index = rawGet(t, key) if index >= 0: result = t.data[index].val else: - when compiles($key): - raise newException(KeyError, "key not found: " & $key) - else: - raise newException(KeyError, "key not found") + raise newException(KeyError, "key not found: " & key) + proc len*(t: StringTableRef): int {.rtlFunc, extern: "nst$1".} = ## Returns the number of keys in `t`. |