forked from TrueCloudLab/neoneo-go
compiler: allow to use return
with no arguments
This commit is contained in:
parent
9afcd71be3
commit
770cff8b91
2 changed files with 14 additions and 5 deletions
|
@ -65,10 +65,12 @@ func (c *funcScope) analyzeVoidCalls(node ast.Node) bool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case *ast.ReturnStmt:
|
case *ast.ReturnStmt:
|
||||||
|
if len(n.Results) > 0 {
|
||||||
switch n.Results[0].(type) {
|
switch n.Results[0].(type) {
|
||||||
case *ast.CallExpr:
|
case *ast.CallExpr:
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
}
|
||||||
case *ast.BinaryExpr:
|
case *ast.BinaryExpr:
|
||||||
return false
|
return false
|
||||||
case *ast.CallExpr:
|
case *ast.CallExpr:
|
||||||
|
|
|
@ -121,7 +121,14 @@ func TestFunctionWithVoidReturn(t *testing.T) {
|
||||||
return x + y
|
return x + y
|
||||||
}
|
}
|
||||||
|
|
||||||
func getSomeInteger() { }
|
func getSomeInteger() { %s }
|
||||||
`
|
`
|
||||||
|
t.Run("EmptyBody", func(t *testing.T) {
|
||||||
|
src := fmt.Sprintf(src, "")
|
||||||
eval(t, src, big.NewInt(6))
|
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