vm: fix (*Stack).Clear to clean up references
This commit is contained in:
parent
930653418d
commit
fd87cd4c54
1 changed files with 3 additions and 0 deletions
|
@ -141,6 +141,9 @@ func initStack(s *Stack, n string, refc *refCounter) {
|
||||||
// Clear clears all elements on the stack and set its length to 0.
|
// Clear clears all elements on the stack and set its length to 0.
|
||||||
func (s *Stack) Clear() {
|
func (s *Stack) Clear() {
|
||||||
if s.elems != nil {
|
if s.elems != nil {
|
||||||
|
for _, el := range s.elems {
|
||||||
|
s.refs.Remove(el.value)
|
||||||
|
}
|
||||||
s.elems = s.elems[:0]
|
s.elems = s.elems[:0]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue