== 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:
parent
caa7f42e8e
commit
4455e5d4b6
1 changed files with 3 additions and 2 deletions
|
|
@ -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 =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue