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 @@
}
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")

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

View check run for this annotation

Codecov / codecov/patch

gnovm/pkg/gnolang/go2gno.go#L485

Added line #L485 was not covered by tests
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_err1.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/parse_err2.gno:12:2: goroutines are not permitted
Loading