diff options
author | Kier Davis <kierdavis@gmail.com> | 2016-06-18 15:43:32 +0100 |
---|---|---|
committer | Kier Davis <kierdavis@gmail.com> | 2016-07-09 17:21:18 +0100 |
commit | edb5a1a5c6b8381c41561f303aa3588ff5fbab69 (patch) | |
tree | da233cf37a00cebab5debf0df4ce1f574b86322f | |
parent | 5e82ffc8d560dd3b2b7bbda034e5436fb036c20d (diff) | |
download | Nim-edb5a1a5c6b8381c41561f303aa3588ff5fbab69.tar.gz |
Fix clear() on CountTable
The record tuples used in CountData.data don't contain an 'hcode' member, unlike Table and OrderedTable, causing the existing clearImpl() implementation to break when attempting to assign to t.data[i].hcode.
-rw-r--r-- | lib/pure/collections/tableimpl.nim | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/pure/collections/tableimpl.nim b/lib/pure/collections/tableimpl.nim index 1bbf19ee9..f73632008 100644 --- a/lib/pure/collections/tableimpl.nim +++ b/lib/pure/collections/tableimpl.nim @@ -142,7 +142,8 @@ template delImpl() {.dirty, immediate.} = template clearImpl() {.dirty, immediate.} = for i in 0 .. <t.data.len: - t.data[i].hcode = 0 + when compiles(t.data[i].hcode): # CountTable records don't contain a hcode + t.data[i].hcode = 0 t.data[i].key = default(type(t.data[i].key)) t.data[i].val = default(type(t.data[i].val)) t.counter = 0 |