-
Notifications
You must be signed in to change notification settings - Fork 384
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
feat: Bound Method Realm support #1257
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1257 +/- ##
=======================================
Coverage 54.74% 54.75%
=======================================
Files 592 592
Lines 79197 79145 -52
=======================================
- Hits 43359 43333 -26
+ Misses 32568 32547 -21
+ Partials 3270 3265 -5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
txtar created by albttx which illustrates the kind of behaviour that should be fixed by this PR (or any continuation of this work) -- place in gnovm/cmd/gno/testadata/gno_test/:
|
Signed-off-by: moul <[email protected]>
75b1d10
to
368d14f
Compare
368d14f
to
23f7173
Compare
Signed-off-by: moul <[email protected]>
Signed-off-by: moul <[email protected]>
Signed-off-by: moul <[email protected]>
When a function is called, it's usually enough to get the pkgpath from where the function is declared, to find out whether we are switching to a new realm or not. But when the function is a bound method, and the method and declared type are defined in a /p/ package, we need to look at the owning (persisting) pkgpath of the receiver, if any. When one is found, it uses that. There are some edge cases to consider, I'm not sure if they are all fixed, but we will find out. Here are some that are considered; 1. if the receiver is an unpersisted new object with method, declared in a p module, it has no realm until it becomes persisted. 2. nil receivers aren't objects, so even if it were stored in a realm, it would be stored by "reference" from a pointervalue which also is not an object, so there's no realm to consider even after persistence. 3. if the method from 1 makes any modifications to the /p/ package's block state, it should result in an error and the tx should fail. 4. if a /p/ declared thing with method gets stored in realm X, it should be possible for realm Y to call it, and have it modify realm X (e.g. say realm X attached a closure to the thing). --------- Signed-off-by: moul <[email protected]> Co-authored-by: moul <[email protected]>
When a function is called, it's usually enough to get the pkgpath from where the function is declared, to find out whether we are switching to a new realm or not.
But when the function is a bound method, and the method and declared type are defined in a /p/ package, we need to look at the owning (persisting) pkgpath of the receiver, if any. When one is found, it uses that.
There are some edge cases to consider, I'm not sure if they are all fixed, but we will find out.
Here are some that are considered;