File tree Expand file tree Collapse file tree 2 files changed +27
-10
lines changed
gno.land/cmd/gnoland/testdata Expand file tree Collapse file tree 2 files changed +27
-10
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,9 @@ stdout OK!
8
8
gnokey maketx call -pkgpath gno.land/r/append -func Append -gas-fee 1000000ugnot -gas-wanted 2000000 -args '1' -broadcast -chainid=tendermint_test test1
9
9
stdout OK!
10
10
11
+ gnokey maketx call -pkgpath gno.land/r/append -func AppendNil -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1
12
+ stdout OK!
13
+
11
14
# Call Append 2
12
15
gnokey maketx call -pkgpath gno.land/r/append -func Append -gas-fee 1000000ugnot -gas-wanted 2000000 -args '2' -broadcast -chainid=tendermint_test test1
13
16
stdout OK!
@@ -60,6 +63,10 @@ gnokey maketx call -pkgpath gno.land/r/append -func Render -gas-fee 1000000ugnot
60
63
stdout '("2-3-42-70-100-" string)'
61
64
stdout OK!
62
65
66
+ gnokey maketx call -pkgpath gno.land/r/append -func Render -gas-fee 1000000ugnot -gas-wanted 2000000 -args 'd' -broadcast -chainid=tendermint_test test1
67
+ stdout '("1-" string)'
68
+ stdout OK!
69
+
63
70
-- append.gno --
64
71
package append
65
72
@@ -69,7 +76,7 @@ import (
69
76
70
77
type T struct{ i int }
71
78
72
- var a, b []T
79
+ var a, b, d []T
73
80
var c = []T{{i: 100}}
74
81
75
82
@@ -104,10 +111,19 @@ func ReassignC() {
104
111
c[0] = T{i: 200}
105
112
}
106
113
114
+ func AppendNil() {
115
+ d = append(d, a...)
116
+ }
117
+
107
118
func Render(path string) string {
119
+ source := a
120
+ if path == "d" {
121
+ source = d
122
+ }
123
+
108
124
var s string
109
- for i:=0;i<len(a );i++{
110
- s+=ufmt.Sprintf("%d-", a [i].i)
125
+ for i:=0;i<len(source );i++{
126
+ s+=ufmt.Sprintf("%d-", source [i].i)
111
127
}
112
128
return s
113
129
}
Original file line number Diff line number Diff line change @@ -210,9 +210,9 @@ func UverseNode() *PackageNode {
210
210
// append(nil, *SliceValue) new list ---------
211
211
list := make ([]TypedValue , argsl )
212
212
if 0 < argsl {
213
- copy (
214
- list [: argsl ],
215
- argsb . List [ argso : argso + argsl ])
213
+ for i := 0 ; i < argsl ; i ++ {
214
+ list [i ] = argsb . List [ argso + i ]. DeepCopy ( m . Alloc , m . Store )
215
+ }
216
216
}
217
217
m .PushValue (TypedValue {
218
218
T : xt ,
@@ -469,11 +469,12 @@ func UverseNode() *PackageNode {
469
469
return
470
470
} else {
471
471
// append(*SliceValue, *NativeValue) new list --------
472
- list := make ([]TypedValue , xvl + argsl )
472
+ listLen := xvl + argsl
473
+ list := make ([]TypedValue , listLen )
473
474
if 0 < xvl {
474
- copy (
475
- list [: xvl ],
476
- xvb . List [ xvo : xvo + xvl ])
475
+ for i := 0 ; i < listLen ; i ++ {
476
+ list [i ] = xvb . List [ xvo + i ]. DeepCopy ( m . Alloc , m . Store )
477
+ }
477
478
}
478
479
if 0 < argsl {
479
480
copyNativeToList (
You can’t perform that action at this time.
0 commit comments