== 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.
This commit is contained in:
Felix Krause
2016-07-07 18:13:12 +02:00
parent caa7f42e8e
commit 4455e5d4b6

View File

@@ -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 =