summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorFelix Krause <contact@flyx.org>2016-07-07 18:13:12 +0200
committerFelix Krause <contact@flyx.org>2016-07-07 18:13:12 +0200
commit4455e5d4b6f30d4ce042c68c8285b2062d146197 (patch)
tree3c3744f442e01fc5008d38b19c5b31a48348de7b /lib
parentcaa7f42e8e75e273ab3f52ada30aed4e06a817d9 (diff)
downloadNim-4455e5d4b6f30d4ce042c68c8285b2062d146197.tar.gz
`==` in tables should not raise KeyError
 * With previous code, the compiler deduced that equalsImpl may raise
   a KeyError. While this could only actually happen in a nasty
   multi-threaded environment, I fixed the code so that it will never happen.
Diffstat (limited to 'lib')
-rw-r--r--lib/pure/collections/tables.nim5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/pure/collections/tables.nim b/lib/pure/collections/tables.nim
index e454a43cb..8d5fbdfc3 100644
--- a/lib/pure/collections/tables.nim
+++ b/lib/pure/collections/tables.nim
@@ -304,8 +304,9 @@ template equalsImpl() =
     # to use the slow route here:
     for key, val in s:
       # prefix notation leads to automatic dereference in case of PTable
-      if not t.hasKey(key): return false
-      if t[key] != val: return false
+      try:
+        if t[key] != val: return false
+      except KeyError: return false
     return true
 
 proc `==`*[A, B](s, t: Table[A, B]): bool =