diff --git a/gnovm/pkg/gnolang/go2gno.go b/gnovm/pkg/gnolang/go2gno.go index 34686dc4cc1..1ef23a0079e 100644 --- a/gnovm/pkg/gnolang/go2gno.go +++ b/gnovm/pkg/gnolang/go2gno.go @@ -433,7 +433,10 @@ func Go2Gno(fs *token.FileSet, gon ast.Node) (n Node) { recv := FieldTypeExpr{} if isMethod { if len(gon.Recv.List) > 1 { - panic("*ast.FuncDecl cannot have multiple receivers") + panic("method has multiple receivers") + } + if len(gon.Recv.List) == 0 { + panic("method has no receiver") } recv = *Go2Gno(fs, gon.Recv.List[0]).(*FieldTypeExpr) } diff --git a/gnovm/tests/files/parse_err0.gno b/gnovm/tests/files/parse_err0.gno new file mode 100644 index 00000000000..88a8e0df132 --- /dev/null +++ b/gnovm/tests/files/parse_err0.gno @@ -0,0 +1,10 @@ +// https://github.com/gnolang/gno/issues/3727 + +package main + +func () A() + +func main() {} + +// Error: +// method has no receiver