forked from gnolang/gno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Norman Meier <[email protected]>
- Loading branch information
Showing
9 changed files
with
135 additions
and
9 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module "gno.land/r/demo/bugs/mis_ownership" | ||
|
||
require ( | ||
"gno.land/r/demo/bugs/steal_ownership" v0.0.0-latest | ||
) |
16 changes: 16 additions & 0 deletions
16
examples/gno.land/r/demo/bugs/mis_ownership/mis_ownership.gno
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,16 @@ | ||
package mis_ownership | ||
|
||
import "gno.land/r/demo/bugs/steal_ownership" | ||
|
||
var ( | ||
x = uint32(42) | ||
ptr = &x | ||
) | ||
|
||
func init() { | ||
steal_ownership.Steal(ptr) | ||
} | ||
|
||
func Mutate() { | ||
*ptr = 21 | ||
} |
16 changes: 9 additions & 7 deletions
16
examples/gno.land/r/demo/bugs/slice_pop_push/slice_pop_push.gno
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 |
---|---|---|
@@ -1,19 +1,21 @@ | ||
package slice_pop_push | ||
|
||
import ( | ||
"strings" | ||
) | ||
|
||
var slice = []string{"undead-element"} | ||
|
||
func Pop() { | ||
func Pop() []string { | ||
slice = slice[:len(slice)-1] | ||
return slice | ||
} | ||
|
||
func Push() { | ||
func Push() []string { | ||
slice = append(slice, "new-element") | ||
return slice | ||
} | ||
|
||
func Render(path string) string { | ||
os := []string{"undead-element-2"} | ||
os = os[:len(os)-1] | ||
os = append(os, "new-element-2") | ||
|
||
return os[0] + slice[0] | ||
return strings.Join(slice, ",") | ||
} |
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 @@ | ||
module "gno.land/r/demo/bugs/steal_ownership" |
7 changes: 7 additions & 0 deletions
7
examples/gno.land/r/demo/bugs/steal_ownership/steal_ownership.gno
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,7 @@ | ||
package steal_ownership | ||
|
||
var ptr *uint32 | ||
|
||
func Steal(xptr *uint32) { | ||
ptr = xptr | ||
} |
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
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,5 @@ | ||
❯ gnokey maketx call -pkgpath "gno.land/r/demo/bugs/mis_ownership" -func "Edit" -gas-fee 1000000ugnot -gas-wanted 2000000 -send "" -broadcast -chainid "dev" -remote "127.0.0.1:26657" onblock-test Native | ||
|
||
Enter password. | ||
--= Error =-- | ||
Data: cannot modify external-realm or non-realm object: object pkg path: gno.land/r/demo/bugs/steal_ownership, realm: gno.land/r/demo/bugs/mis_ownership |