-
Notifications
You must be signed in to change notification settings - Fork 379
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: handle assignments to dereferenced pointer values #1398
Closed
Closed
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
2c023cf
recurse on DidUpdate for all ArrayValue elements
deelawn c4ed7e4
undid incorrect simplification
deelawn 09df263
reworked solution
deelawn cec8f0d
Added txtar test
deelawn 7ecb905
Merge branch 'master' into bug/slice-append
deelawn 91b4586
alternate approach to saving nested reference values
deelawn b2e153a
scoped back which types of values can be saved dynamically
deelawn 4b4b25c
Revert "alternate approach to saving nested reference values"
deelawn 7df8c80
handle nested slices when appending to slices under capacity
deelawn 77f79a8
Merge branch 'master' into bug/slice-append
deelawn 6821083
wrap new sanity check in debug
deelawn 811b5f6
Merge branch 'master' into bug/slice-append
deelawn b4279e9
fixed up txtar test
deelawn daa6914
added XX annotation
deelawn 750ec38
reworked solution to avoid looping in DidUpdate
deelawn 7392890
txtar test for 1167 test case
deelawn 9c0c35a
improved append test and added more append deep copies
deelawn de2a233
handle additional append cases
deelawn 1d7497c
first stab at a solution that fixes the issue
deelawn 9133293
added realm qualifier
deelawn ed2ad73
use object accessor method
deelawn e7589fe
add txtar; fix pkg path in other
deelawn bb9fb88
Merge branch 'master' into bug/ptr-deref-assgn
deelawn d03eec7
restore object info copy functionality
deelawn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Reproducible Test for https://github.com/gnolang/gno/issues/1167 | ||
|
||
gnoland start | ||
|
||
# add contract | ||
gnokey maketx addpkg -pkgdir $WORK -pkgpath gno.land/r/xx -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1 | ||
stdout OK! | ||
|
||
# execute New | ||
gnokey maketx call -pkgpath gno.land/r/xx -func New -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1 | ||
stdout OK! | ||
|
||
# execute Delta for the first time | ||
gnokey maketx call -pkgpath gno.land/r/xx -func Delta -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1 | ||
stdout OK! | ||
|
||
-- realm.gno -- | ||
package xx | ||
|
||
import ( | ||
"strconv" | ||
|
||
"gno.land/p/demo/avl" | ||
) | ||
|
||
type Move struct { | ||
N1, N2, N3 byte | ||
} | ||
|
||
type S struct { | ||
Moves []Move | ||
} | ||
|
||
func (s S) clone() S { | ||
mv := s.Moves | ||
return S{Moves: mv} | ||
} | ||
|
||
func (olds S) change() S { | ||
s := olds.clone() | ||
|
||
counter++ | ||
s.Moves = append([]Move{}, s.Moves...) | ||
s.Moves = append(s.Moves, Move{counter, counter, counter}) | ||
return s | ||
} | ||
|
||
var el *S | ||
var counter byte | ||
|
||
func New() { | ||
el = &S{} | ||
} | ||
|
||
func Delta() string { | ||
n := el.change() | ||
*el = n | ||
return Values() | ||
} | ||
|
||
func Values() string { | ||
s := "" | ||
for _, val := range el.Moves { | ||
s += strconv.Itoa(int(val.N1)) + "," + strconv.Itoa(int(val.N2)) + "," + strconv.Itoa(int(val.N3)) + ";" | ||
} | ||
return s | ||
} |
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An index of zero could mean it's the zero'th element of an array, or the zero'th element of a block,
or whatever the .Base type is. The Index doesn't say much but the .Base type says more but depends on what you mean by a realm object. Like a PackageValue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right that an index of zero can mean more than one thing depending on the context, but in this case the realm is not nil and the base is nil, so I think this means that a value is being assigned to a realm object. I'm not sure what the difference is between realm object and PackageValue; they might be synonymous -- the values that are persisted from one block to the next; variables that are declared in a realm and are not local to any function or method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok at least the comment needs fixing, "A base of nil indicates"?
A base of nil indicates an assignment to an escaped object, or a new one that just hasn't been persisted yet.
An escaped object has no owner.
All persisted objects are realm objects.
Some are substructures (base == parent, ref==1), others are escaped.
All realms have an associated package value but not all packages are realms. Depends on the PkgPath name.