mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-03 23:02:27 +00:00
compiler: calculate stack size more precisely
When calculating number of local variables, only defining assignments (i.e. via `:=`) must be taken into account.
This commit is contained in:
parent
9b5dab57e8
commit
a43c9b9246
2 changed files with 21 additions and 1 deletions
|
@ -3,6 +3,8 @@ package compiler_test
|
|||
import (
|
||||
"math/big"
|
||||
"testing"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm"
|
||||
)
|
||||
|
||||
var assignTestCases = []testCase{
|
||||
|
@ -133,3 +135,18 @@ var assignTestCases = []testCase{
|
|||
func TestAssignments(t *testing.T) {
|
||||
runTestCases(t, assignTestCases)
|
||||
}
|
||||
|
||||
func TestManyAssignments(t *testing.T) {
|
||||
src1 := `package foo
|
||||
func Main() int {
|
||||
a := 0
|
||||
`
|
||||
src2 := `return a
|
||||
}`
|
||||
|
||||
for i := 0; i < vm.MaxArraySize; i++ {
|
||||
src1 += "a += 1\n"
|
||||
}
|
||||
|
||||
eval(t, src1+src2, big.NewInt(vm.MaxArraySize))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue