compiler: count current amount of locals correctly
This commit is contained in:
parent
637f75d9ef
commit
c57d4cfff2
2 changed files with 21 additions and 4 deletions
|
@ -169,3 +169,18 @@ func TestFunctionWithMultipleArgumentNames(t *testing.T) {
|
|||
}`
|
||||
eval(t, src, big.NewInt(3))
|
||||
}
|
||||
|
||||
func TestLocalsCount(t *testing.T) {
|
||||
src := `package foo
|
||||
func f(a, b, c int) int {
|
||||
sum := a
|
||||
for i := 0; i < c; i++ {
|
||||
sum += b
|
||||
}
|
||||
return sum
|
||||
}
|
||||
func Main() int {
|
||||
return f(1, 2, 3)
|
||||
}`
|
||||
eval(t, src, big.NewInt(7))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue