diff --git a/examples/gno.land/r/demo/bugs/bugmin/bugmin.gno b/examples/gno.land/r/demo/bugs/bugmin/bugmin.gno new file mode 100644 index 00000000000..74d658193bb --- /dev/null +++ b/examples/gno.land/r/demo/bugs/bugmin/bugmin.gno @@ -0,0 +1,22 @@ +package bugmin + +import ( + "strconv" + "strings" +) + +var slice = []string{"undead-element"} + +func Pop() { + slice = slice[:len(slice)-1] +} + +func Push() { + slice = append(slice, "new-element") +} + +func Render(path string) string { + str := strings.Join(slice, ", ") + "\n\n" + str += "len: " + strconv.Itoa(len(slice)) + "\n\n" + return str +} diff --git a/examples/gno.land/r/demo/bugs/bugmin/gno.mod b/examples/gno.land/r/demo/bugs/bugmin/gno.mod new file mode 100644 index 00000000000..36cdd9d76a0 --- /dev/null +++ b/examples/gno.land/r/demo/bugs/bugmin/gno.mod @@ -0,0 +1 @@ +module "gno.land/r/demo/bugs/bugmin" \ No newline at end of file diff --git a/examples/gno.land/r/demo/bugs/slice_splice/gno.mod b/examples/gno.land/r/demo/bugs/slice_splice/gno.mod new file mode 100644 index 00000000000..f7a638504d0 --- /dev/null +++ b/examples/gno.land/r/demo/bugs/slice_splice/gno.mod @@ -0,0 +1 @@ +module "gno.land/r/demo/bugs/slice_splice" \ No newline at end of file diff --git a/examples/gno.land/r/demo/bugs/slice_splice/slice_splice.gno b/examples/gno.land/r/demo/bugs/slice_splice/slice_splice.gno new file mode 100644 index 00000000000..aa7a2eb03ba --- /dev/null +++ b/examples/gno.land/r/demo/bugs/slice_splice/slice_splice.gno @@ -0,0 +1,20 @@ +package slice_splice + +import ( + "strings" +) + +var slice = []string{} + +func Push() { + slice = append(slice, "1", "2", "3", "4", "5", "6", "7", "8", "9", "10") +} + +func Splice() []string { + slice = slice[4:5] + return slice +} + +func Render(path string) string { + return strings.Join(slice, ",") +} diff --git a/examples/gno.land/r/demo/bugs/two_slices_one_array/gno.mod b/examples/gno.land/r/demo/bugs/two_slices_one_array/gno.mod new file mode 100644 index 00000000000..acc48a55204 --- /dev/null +++ b/examples/gno.land/r/demo/bugs/two_slices_one_array/gno.mod @@ -0,0 +1 @@ +module "gno.land/r/demo/bugs/two_slices_one_array" \ No newline at end of file diff --git a/examples/gno.land/r/demo/bugs/two_slices_one_array/two_slices_one_array.gno b/examples/gno.land/r/demo/bugs/two_slices_one_array/two_slices_one_array.gno new file mode 100644 index 00000000000..3799f569e6b --- /dev/null +++ b/examples/gno.land/r/demo/bugs/two_slices_one_array/two_slices_one_array.gno @@ -0,0 +1,20 @@ +package two_slices_one_array + +import ( + "strings" +) + +var ( + slice = []string{"1", "2", "3", "4", "5", "6", "7", "8", "9", "10"} + sub1 []string = nil + sub2 []string = nil +) + +func Split() { + sub1 = slice[0:5] + sub2 = slice[5:] +} + +func Render(path string) string { + return "slice: " + strings.Join(slice, ",") + "\n\n" + "sub1: " + strings.Join(sub1, ",") + "\n\n" + "sub2: " + strings.Join(sub2, ",") +}