compiler: count local variables on the go

Create local variables as they are needed and remove `INITSLOT`
if there were no locals. This helps to eliminate a whole class
of bugs when calculated and real amount mismatched.
This commit is contained in:
Evgeniy Stratonikov 2021-04-28 16:10:44 +03:00
parent bfa2bafb04
commit b693d54282
9 changed files with 181 additions and 230 deletions

View file

@ -137,3 +137,14 @@ func TestRecover(t *testing.T) {
eval(t, src, big.NewInt(5))
})
}
func TestDeferNoGlobals(t *testing.T) {
src := `package foo
func Main() int {
a := 1
defer func() { recover() }()
panic("msg")
return a
}`
eval(t, src, big.NewInt(0))
}