-
Notifications
You must be signed in to change notification settings - Fork 378
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
Conversation
This reverts commit 91b4586.
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #1398 +/- ##
==========================================
- Coverage 55.84% 55.84% -0.01%
==========================================
Files 431 431
Lines 65747 65782 +35
==========================================
+ Hits 36716 36734 +18
- Misses 26158 26172 +14
- Partials 2873 2876 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
Can you elaborate a second on these changes?
Were they not reproducing 1167 correctly?
taking a look... |
@@ -273,7 +273,35 @@ func (pv PointerValue) Assign2(alloc *Allocator, store Store, rlm *Realm, tv2 Ty | |||
// Special case of DataByte into (base=*SliceValue).Data. | |||
pv.TV.SetDataByte(tv2.GetUint8()) | |||
return | |||
} else if rlm != nil && pv.Base == nil && pv.Index == 0 { | |||
// An index of zero indicates this is an assignment to a realm |
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.
Sidenote: This depends on https://github.com/gnolang/gno/pull/1305/files DeepCopy but DeepCopy is a misnomer. |
5e2948a
to
5425504
Compare
I think this is the approach we should take: https://github.com/gnolang/gno/pull/1501/files generally speaking. |
Closing in favor of #1501 |
Addresses #1326
This is still a WIP and I need to do a lot more testing with different cases and tweak it accordingly. Before I spend the time to do that, I'm requesting feedback as to whether or not this is the correct approach to fixing this issue. I tried fixing it in a few different places prior to this PR; this was the only place I was successful in doing so. Perhaps the reference value should be resolved and the base value set earlier; I'm not sure.
cc @jaekwon
Contributors' checklist...
BREAKING CHANGE: xxx
message was included in the description