Merge pull request #2267 from SSPkrolik/tables-getter-fix

Fixed table getter not compiling when table key type had not '$' proc ...
This commit is contained in:
Andreas Rumpf
2015-03-06 10:18:03 +01:00

View File

@@ -196,7 +196,11 @@ proc mget*[A, B](t: var Table[A, B], key: A): var B =
var hc: THash
var index = rawGet(t, key, hc)
if index >= 0: result = t.data[index].val
else: raise newException(KeyError, "key not found: " & $key)
else:
when compiles($key):
raise newException(KeyError, "key not found: " & $key)
else:
raise newException(KeyError, "key not found")
iterator allValues*[A, B](t: Table[A, B]; key: A): B =
## iterates over any value in the table `t` that belongs to the given `key`.