mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-22 08:47:28 +01:00
Ban duplicate loop labels
This commit is contained in:
1 parent
ee23f8b3d9
commit
4a89913a9b
2 files changed
+18
-3
No files matched your search
+10
-1
@@ -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 {
|
||||
|
||||
Reference in new issue
Block a user