We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Calling a realm that uses std.PrevRealm has not the same behavior if called in a realm's var block or in the init block
std.PrevRealm
var
init
package var_prev_realm import ( "std" "gno.land/r/demo/tests" ) var ( varRealm = tests.GetPrevRealm() initRealm std.Realm ) func init() { initRealm = tests.GetPrevRealm() } func Render(path string) string { s := "" s += "Var block realm:\n\nPackage path: " + varRealm.PkgPath() + "\n\nAddress: " + varRealm.Addr().String() + "\n\n" s += "Init block realm:\n\nPackage path: " + initRealm.PkgPath() + "\n\nAddress: " + initRealm.Addr().String() + "\n\n" return s }
tests.GetPrevRealm() returns the same whether called in var or init block
tests.GetPrevRealm()
Not sure if this is a bug or intended behavior, would love to know the rationale if this is intended
The text was updated successfully, but these errors were encountered:
Hey @n0izn0iz not sure this is relevant anymore. With this code:
package mypkg import ( "std" "gno.land/p/demo/ufmt" "gno.land/r/demo/tests" ) var ( toplvl = std.PrevRealm().Addr() initlvl std.Address toplvltest = tests.GetPrevRealm().Addr() initlvltest std.Address ) func init() { initlvl = std.PrevRealm().Addr() initlvltest = tests.GetPrevRealm().Addr() } func Render(_ string) string { out := ufmt.Sprintf("### prevrealm in this realm (=deployer):\n\ntoplvl: %s\n\n initlvl: %s\n\n", toplvl, initlvl) out += ufmt.Sprintf("### prevrealm in tests (=current realm addr):\n\ntoplvl using test: %s\n\n initlvl using test: %s\n\n", toplvltest, initlvltest) return out }
We get the following output:
Above is tested locally, and here you can see it deployed: https://gno.land/r/leon/issues/mypkg
Possibly this was fixed somewhere in between. Can you see if your issue is still relevant, and close it if it's not?
Sorry, something went wrong.
looks good indeed
No branches or pull requests
Calling a realm that uses std.PrevRealm() has different behavior in var and init blocks
Description
Calling a realm that uses
std.PrevRealm
has not the same behavior if called in a realm'svar
block or in theinit
blockYour environment
Steps to reproduce
Expected behaviour
tests.GetPrevRealm()
returns the same whether called invar
orinit
blockActual behaviour
Additional info
Not sure if this is a bug or intended behavior, would love to know the rationale if this is intended
The text was updated successfully, but these errors were encountered: