summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKier Davis <kierdavis@gmail.com>2016-06-18 15:43:32 +0100
committerKier Davis <kierdavis@gmail.com>2016-07-09 17:21:18 +0100
commitedb5a1a5c6b8381c41561f303aa3588ff5fbab69 (patch)
treeda233cf37a00cebab5debf0df4ce1f574b86322f
parent5e82ffc8d560dd3b2b7bbda034e5436fb036c20d (diff)
downloadNim-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.nim3
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