Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gnolang): make Go2Gno return a prespective error instead of sudden/elusive runtime panic with a bad receiver #3733

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion gnovm/pkg/gnolang/go2gno.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,10 @@
recv := FieldTypeExpr{}
if isMethod {
if len(gon.Recv.List) > 1 {
panic("*ast.FuncDecl cannot have multiple receivers")
panic("method has multiple receivers")

Check warning on line 436 in gnovm/pkg/gnolang/go2gno.go

View check run for this annotation

Codecov / codecov/patch

gnovm/pkg/gnolang/go2gno.go#L436

Added line #L436 was not covered by tests
}
if len(gon.Recv.List) == 0 {
panic("method has no receiver")
}
recv = *Go2Gno(fs, gon.Recv.List[0]).(*FieldTypeExpr)
}
Expand Down
10 changes: 10 additions & 0 deletions gnovm/tests/files/parse_err0.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// https://github.com/gnolang/gno/issues/3727

package main

func () A()

func main() {}

// Error:
// method has no receiver
Loading