diff --git a/gnovm/pkg/gnolang/preprocess.go b/gnovm/pkg/gnolang/preprocess.go index 61096626f28..598cd1b63df 100644 --- a/gnovm/pkg/gnolang/preprocess.go +++ b/gnovm/pkg/gnolang/preprocess.go @@ -1738,7 +1738,12 @@ func Preprocess(store Store, ctx BlockNode, n Node) Node { case *KeyValueExpr: // NOTE: For simplicity we just // use the *CompositeLitExpr. - + // TRANS_LEAVE ----------------------- + case *StarExpr: + xt := evalStaticTypeOf(store, last, n.X) + if xt.Kind() != PointerKind && xt.Kind() != TypeKind { + panic(fmt.Sprintf("invalid operation: cannot indirect %s (variable of type %s)", n.X.String(), xt.String())) + } // TRANS_LEAVE ----------------------- case *SelectorExpr: xt := evalStaticTypeOf(store, last, n.X) diff --git a/gnovm/tests/files/ptr9.gno b/gnovm/tests/files/ptr9.gno new file mode 100644 index 00000000000..6e104942d81 --- /dev/null +++ b/gnovm/tests/files/ptr9.gno @@ -0,0 +1,9 @@ +package main + +func main() { + v := 1 + println(*v) +} + +// Error: +// main/files/ptr9.gno:5:10: invalid operation: cannot indirect v (variable of type int)