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:
parent
bfa2bafb04
commit
b693d54282
9 changed files with 181 additions and 230 deletions
|
@ -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))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue