GNOME Bugzilla – Bug 664630
Default Iterator for Gee HashMap seems to be broken.
Last modified: 2013-05-11 19:18:35 UTC
Created attachment 201986 [details] Test case with comments and output to illustrate the problem The default iterator for instances of HashMap seems to be broken. I.e.: var foos = new Gee.HashMap<int, Foo> (keyfunc, eqfunc); foreach (var f in foos) <do stuff with f> Seems to result in an iterator over the value type of foos, rather than Gee.Iterable<Gee.Map.Entry<K,V>> - which is what the VAPI for AbstractMap in Gee 0.6.1 (Fedora package libgee-0.6.1-3.fc16.x86_64) seems to suggest should be the type. Also, even if this were a problem in my understanding and Foo is the correct type and the iterator is intended to be over the values, the iterator is still functionally broken: it does not return all the values, instead it returns a nil entry.
(In reply to comment #0) > Created an attachment (id=201986) [details] > Test case with comments and output to illustrate the problem > > The default iterator for instances of HashMap seems to be broken. I.e.: > > var foos = new Gee.HashMap<int, Foo> (keyfunc, eqfunc); > > foreach (var f in foos) > <do stuff with f> > > Seems to result in an iterator over the value type of foos, rather than > Gee.Iterable<Gee.Map.Entry<K,V>> - which is what the VAPI for AbstractMap in > Gee 0.6.1 (Fedora package libgee-0.6.1-3.fc16.x86_64) seems to suggest should > be the type. > What's the generated code? > Also, even if this were a problem in my understanding and Foo is the correct > type and the iterator is intended to be over the values, the iterator is still > functionally broken: it does not return all the values, instead it returns a > nil entry. It is definitly bug. Could you post separate bug for libgee (in this way I won't forgot to check it, also it probably needs to be fixed separately so it will help bookkeeping) if it is not fixed in 0.6.3 version (0.6.2 and 0.6.3 are bugfix releases).
Which part of this bug is libgee, so I can create a sensible bug for that? :)
(In reply to comment #2) > Which part of this bug is libgee, so I can create a sensible bug for that? :) I would say: "the iterator is still functionally broken: it does not return all the values, instead it returns a nil entry.". It might have root cause from Vala problem but at least it sounds like it might have something in common with libgee itself.
As I see it, this is because Gee.Map also supports 'get/size' which takes precedence over the 'iterator' method. foreach (foo in foos) { ... } using get/size, it will iterate over the range 0..size even if e.g. 0 is not a key in the map. A solution would be to introduce a new attribute which disables 'get/size' iteration. Maybe even something like this: [NoSyntaxSupport] public V get (V value) { ... }
*** This bug has been marked as a duplicate of bug 645850 ***