mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-05 03:58:23 +00:00
compiler: allow to use return
with no arguments
This commit is contained in:
parent
e097e86bfa
commit
2a6be8ceef
2 changed files with 14 additions and 5 deletions
|
@ -65,9 +65,11 @@ func (c *funcScope) analyzeVoidCalls(node ast.Node) bool {
|
|||
}
|
||||
}
|
||||
case *ast.ReturnStmt:
|
||||
switch n.Results[0].(type) {
|
||||
case *ast.CallExpr:
|
||||
return false
|
||||
if len(n.Results) > 0 {
|
||||
switch n.Results[0].(type) {
|
||||
case *ast.CallExpr:
|
||||
return false
|
||||
}
|
||||
}
|
||||
case *ast.BinaryExpr:
|
||||
return false
|
||||
|
|
|
@ -121,7 +121,14 @@ func TestFunctionWithVoidReturn(t *testing.T) {
|
|||
return x + y
|
||||
}
|
||||
|
||||
func getSomeInteger() { }
|
||||
func getSomeInteger() { %s }
|
||||
`
|
||||
eval(t, src, big.NewInt(6))
|
||||
t.Run("EmptyBody", func(t *testing.T) {
|
||||
src := fmt.Sprintf(src, "")
|
||||
eval(t, src, big.NewInt(6))
|
||||
})
|
||||
t.Run("SingleReturn", func(t *testing.T) {
|
||||
src := fmt.Sprintf(src, "return")
|
||||
eval(t, src, big.NewInt(6))
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue