fix(gnovm): ignore blank fields in struct equality and map keys#5784
Open
omarsy wants to merge 4 commits into
Open
fix(gnovm): ignore blank fields in struct equality and map keys#5784omarsy wants to merge 4 commits into
omarsy wants to merge 4 commits into
Conversation
Collaborator
🛠 PR Checks SummaryAll Automated Checks passed. ✅ Manual Checks (for Reviewers):
Read More🤖 This bot helps streamline PR reviews by verifying automated checks and providing guidance for contributors and reviewers. ✅ Automated Checks (for Contributors):🟢 Maintainers must be able to edit this pull request (more info) ☑️ Contributor Actions:
☑️ Reviewer Actions:
📚 Resources:Debug
|
…blank-field-equality # Conflicts: # gnovm/pkg/gnolang/op_binary.go # gnovm/tests/files/map48.gno
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
davd-gzl
approved these changes
Jun 8, 2026
davd-gzl
left a comment
Member
There was a problem hiding this comment.
It miss the test where all keys are blank: struct{ _, _ int }
This is a behavioral break for any persisted code using blank key. This should not be a problem
This was referenced Jun 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes Go 1.17 spec mismatches in Gno struct equality and map keys.
The Go spec says struct equality compares corresponding non-blank fields. Gno was also comparing fields named
_, so values like:incorrectly evaluated to
false.Gno also encoded blank struct fields into map keys, so a lookup such as:
missed the existing entry even though the keys are equal under the Go spec.
This updates
StructKindequality and struct map-key encoding to skip blank fields while preserving existing comparability checks. A companion negative test verifies that blank fields still count for comparability, so a struct containing_ []intremains non-comparable.Spec reference:
https://go.googlesource.com/go/+/refs/tags/go1.17.5/doc/go_spec.html#Comparison_operators
Tests
Note: a full
go test ./gnovm/pkg/gnolang -count=1was started before the map-key follow-up but did not complete after several minutes, so it was stopped.AI Disclosure
This PR was prepared with AI assistance.