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

fix: remove incorrect type assertion when reading values from storage #1606

Merged
merged 6 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions gno.land/cmd/gnoland/testdata/issue-1588.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Reproducible Test for https://github.com/gnolang/gno/issues/1588

gnoland start

# add contract
gnokey maketx addpkg -pkgdir $WORK -pkgpath gno.land/r/demo/xx -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1
stdout OK!

gnokey maketx call -pkgpath gno.land/r/demo/xx -func DefineFamily -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1
stdout OK!

gnokey maketx call -pkgpath gno.land/r/demo/xx -func GetOutcastChildAge -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1
stdout OK!
stdout '(10 int)'

-- gno.mod --
module gno.land/r/demo/xx

-- realm.gno --
package xx

type Parent struct {
children []Child
outcastChild *Child
}

type Child struct {
age int
}

var parent Parent

func DefineFamily() {
parent = Parent{
children: []Child{
{age: 10},
{age: 20},
},
}
parent.outcastChild = &parent.children[0]
}

func GetOutcastChildAge() int {
if parent.outcastChild == nil {
return -1
}
return parent.outcastChild.age
}
2 changes: 1 addition & 1 deletion gnovm/pkg/gnolang/values.go
Original file line number Diff line number Diff line change
Expand Up @@ -2533,7 +2533,7 @@ func fillValueTV(store Store, tv *TypedValue) *TypedValue {
cv.Base = base
switch cb := base.(type) {
case *ArrayValue:
et := baseOf(tv.T).(*ArrayType).Elt
et := baseOf(tv.T).(*PointerType).Elt
epv := cb.GetPointerAtIndexInt2(store, cv.Index, et)
cv.TV = epv.TV // TODO optimize? (epv.* ignored)
case *StructValue:
Expand Down
Loading