Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Unexpected result of set-contains? #400
I am seeing unexpected results when creating a set, adding elements with
(use scheme.set) (define my-set (let loop ((a-set (set eq-comparator)) (numbers (iota 20))) (if (null? numbers) a-set (loop (set-adjoin a-set (car numbers)) (cdr numbers))))) (print (set-size my-set)) ;; length is correct (print (set->list my-set)) ;; everything shows up ;; some of these show up as #f! (set-for-each (lambda (x) (print "Set contains " x "? " (set-contains? my-set x))) my-set)
I am getting these results:
As far as I can tell,
The actual results may be different on other computers, I don't know. When I use 10 elements, they all show up. With 20, I am starting to see the above.
If I create the set with
I am using Gauche 0.9.6 (Homebrew, latest version) on macOS Sierra (10.12.6). To be precise,
added a commit
Dec 1, 2018
Turned out this is an old bug in hash-table-copy that hadn't been noticed (amazingly!). It only surfaces when you copy a hashtable then add a bunch of entries to the copy so that it triggers rehashing. I guess it haven't been noticed since we've been using hashtables as mutable object for most of the time. The set interface is mostly functional, so internally it copies hashtables, hence it finally came up. Thanks for reporting!