== 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
commit 4455e5d4b6

View file

@ -304,8 +304,9 @@ template equalsImpl() =
# to use the slow route here: # to use the slow route here:
for key, val in s: for key, val in s:
# prefix notation leads to automatic dereference in case of PTable # prefix notation leads to automatic dereference in case of PTable
if not t.hasKey(key): return false try:
if t[key] != val: return false if t[key] != val: return false
except KeyError: return false
return true return true
proc `==`*[A, B](s, t: Table[A, B]): bool = proc `==`*[A, B](s, t: Table[A, B]): bool =