Skip to content
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

WIP fix(gnovm): correct map key persistence #3127

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

ltzmaxwell
Copy link
Contributor

@ltzmaxwell ltzmaxwell commented Nov 14, 2024

closes: #2060

Contributors' checklist...
  • Added new tests, or not needed, or not feasible
  • Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory
  • Updated the official documentation or not needed
  • No breaking changes were made, or a BREAKING CHANGE: xxx message was included in the description
  • Added references to related issues and PRs
  • Provided any useful hints for running manual tests

@github-actions github-actions bot added 📦 🤖 gnovm Issues or PRs gnovm related 📦 ⛰️ gno.land Issues or PRs gno.land package related labels Nov 14, 2024
@ltzmaxwell
Copy link
Contributor Author

ltzmaxwell commented Nov 15, 2024

another bug identified:

// PKGPATH: gno.land/r/ptr_map
package ptr_map

import "fmt"

type MyStruct struct {
	Name string
}

var (
	m = map[[1]*MyStruct]string{}

	i1   = &MyStruct{Name: "alice"}
	key1 = [1]*MyStruct{i1}
)

func init() {
	m[key1] = "first key"
}

func main() {
	fmt.Println("Value for key1:", m[key1])
}

// Error:
// interface conversion: gnolang.Value is gnolang.RefValue, not *gnolang.ArrayValue

this if fixed.

@ltzmaxwell
Copy link
Contributor Author

ltzmaxwell commented Nov 15, 2024

also this, is it counterintuitive?

// PKGPATH: gno.land/r/ptr_map
package ptr_map

type MyStruct struct {
	Name string
}

var (
	m = map[[1]*MyStruct]string{}

	i1 = &MyStruct{Name: "alice"}
)

func main() {
	// Create an array of pointers to MyStruct
	key1 := [1]*MyStruct{i1}
	m[key1] = "first key"
}
// Error:
// unexpected unreal object

this is fixed but should consider the side effects on storage.

Copy link

codecov bot commented Nov 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 63.34%. Comparing base (7ef606c) to head (50f1f51).
Report is 13 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3127   +/-   ##
=======================================
  Coverage   63.34%   63.34%           
=======================================
  Files         548      548           
  Lines       78680    78655   -25     
=======================================
- Hits        49836    49826   -10     
+ Misses      25482    25466   -16     
- Partials     3362     3363    +1     
Flag Coverage Δ
contribs/gnodev 61.16% <ø> (ø)
contribs/gnofaucet 14.82% <ø> (ø)
misc/genstd 79.72% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Kouteki Kouteki added the in focus Core team is prioritizing this work label Nov 15, 2024
@Kouteki Kouteki added this to the 🚀 Mainnet launch milestone Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in focus Core team is prioritizing this work 📦 ⛰️ gno.land Issues or PRs gno.land package related 📦 🤖 gnovm Issues or PRs gnovm related
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

[GnoVM] bug: inconsistent map key
2 participants