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): prescriptively reject *ast.(IndexListExpr, GoStmt) as unrecognized for Gno #3752

Merged
7 changes: 7 additions & 0 deletions gnovm/pkg/gnolang/go2gno.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,13 @@ func Go2Gno(fs *token.FileSet, gon ast.Node) (n Node) {
}
case *ast.EmptyStmt:
return &EmptyStmt{}
case *ast.IndexListExpr:
if len(gon.Indices) > 1 {
panicWithPos("invalid operation: more than one index")
}
panicWithPos("invalid operation: indexList is not permitted in Gno")
case *ast.GoStmt:
panicWithPos("goroutines are not permitted")
default:
panicWithPos("unknown Go type %v: %s\n",
reflect.TypeOf(gon),
Expand Down
16 changes: 16 additions & 0 deletions gnovm/tests/files/parse_err1.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// https://github.com/gnolang/gno/issues/3731

package main

type node struct {
r []int
}

func (n *node) foo(targ, wndex int) {
_ = n.r[targ, wndex]
}

func main() {}

// Error:
// files/parse_indexListExpr.gno:10:6: invalid operation: more than one index
16 changes: 16 additions & 0 deletions gnovm/tests/files/parse_err2.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// https://github.com/gnolang/gno/issues/3751

package math

import "testing"

func Add(a, b int) int {
return a + b
}

func TestAdd(t *testing.T) {
go Add(1, 1)
}

// Error:
// files/goroutine_not_supported.gno:12:5: goroutines are not permitted
Loading