compiler: refactor void calls processing

Call result is not used only if it occurs inside a `ExprStmt`.
Otherwise (`IfStmt`, `BinExpr`...) it is used.

Fix #1495.
This commit is contained in:
Evgenii Stratonikov 2020-10-19 10:43:45 +03:00
parent 6849499f56
commit 01ccaefe2f
2 changed files with 13 additions and 66 deletions

View file

@ -86,6 +86,15 @@ func TestNotAssignedFunctionCall(t *testing.T) {
}`
eval(t, src, big.NewInt(42))
})
t.Run("VarDecl", func(t *testing.T) {
src := `package foo
func foo() []int { return []int{1} }
func Main() int {
var x = foo()
return len(x)
}`
eval(t, src, big.NewInt(1))
})
}
func TestMultipleFunctionCalls(t *testing.T) {