-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spurious nil table keys during iteration #93
Comments
It is possible to get a nil key return value and for For example if a table
(syntax above is not quite correct because I should write If you encounter another type of situation then please give me an example so that I can understand and fix the issue. |
Aah, thank you for this explanation, that makes a lot of sense. The thing that threw me off is that often in Go, a bool return value like this indicates whether there is another entry. I'd like to suggest to extend the documentation of // Next returns the key-value pair that comes after k in the table t.
// If k is NilValue, the first key-value pair in the table t is returned.
// If k is the last key in the table t, a pair of NilValues is returned.
// If the table t is empty, the returned key-value pair is always a pair of NilValues, regardless of k.
// In all cases, ok is true if and only if k is either NilValue or a key present in the table t. Thanks again! |
When iterating over a
runtime.Table
using theNext()
method, I occasionally get a nil key return value withok == true
.I can try putting together a minimal example of the bug, however, looking at the source code, I see this:
golua/runtime/hashtable.go
Line 361 in 4f77264
This looks like it should be
return NilValue, NilValue, false
instead in the firstif
. Could this already be the fix?The text was updated successfully, but these errors were encountered: