Ban duplicate loop labels

This commit is contained in:
Nigel Tao committed 2020-04-03 10:33:05 +11:00
1 parent ee23f8b3d9
commit 4a89913a9b
2 files changed
+18 -3

No files matched your search

+10 -1
View File
@@ -257,8 +257,17 @@ type Loop interface {
type LoopStack []Loop
func (s *LoopStack) Push(l Loop) {
// Push returns false if an existing Loop has the same non-zero label.
func (s *LoopStack) Push(l Loop) (ok bool) {
if label := l.Label(); label != 0 {
for _, o := range *s {
if label == o.Label() {
return false
}
}
}
*s = append(*s, l)
return true
}
func (s *LoopStack) Pop() Loop {