diff --git a/gnovm/pkg/gnolang/preprocess.go b/gnovm/pkg/gnolang/preprocess.go index c86edb0e515..1d215e4d94b 100644 --- a/gnovm/pkg/gnolang/preprocess.go +++ b/gnovm/pkg/gnolang/preprocess.go @@ -978,11 +978,14 @@ func Preprocess(store Store, ctx BlockNode, n Node) Node { arg0)) } } - convertConst(store, last, arg0, ct) constConverted = true + case SliceKind: + if ct.Elem().Kind() == Uint8Kind { // bypass []byte("xxx") + n.SetAttribute(ATTR_TYPEOF_VALUE, ct) + return n, TRANS_CONTINUE + } } - // (const) untyped decimal -> float64. // (const) untyped bigint -> int. if !constConverted { diff --git a/gnovm/tests/files/byte_slice_issue1570.gno b/gnovm/tests/files/byte_slice_issue1570.gno new file mode 100644 index 00000000000..c1956f3d15d --- /dev/null +++ b/gnovm/tests/files/byte_slice_issue1570.gno @@ -0,0 +1,15 @@ +package main + +func main() { + for i := 0; i < 2; i++ { + l := []byte("lead") + if i == 0 { + l[0] = 'f' + } + println(string(l)) + } +} + +// Output: +// fead +// lead