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:
parent
6849499f56
commit
01ccaefe2f
2 changed files with 13 additions and 66 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue