Source file test/fixedbugs/issue17449.go
1 // errorcheck -0 -race 2 3 //go:build (linux && amd64) || (linux && ppc64le) || (darwin && amd64) || (freebsd && amd64) || (netbsd && amd64) || (windows && amd64) 4 5 // Copyright 2016 The Go Authors. All rights reserved. 6 // Use of this source code is governed by a BSD-style 7 // license that can be found in the LICENSE file. 8 9 // Issue 17449: race instrumentation copies over previous instrumented nodes from parents block into child's Ninit block. 10 // This code surfaces the duplication at compile time because of generated inline labels. 11 12 package master 13 14 type PriorityList struct { 15 elems []interface{} 16 } 17 18 func (x *PriorityList) Len() int { return len(x.elems) } 19 20 func (l *PriorityList) remove(i int) interface{} { 21 elem := l.elems[i] 22 l.elems = append(l.elems[:i], l.elems[i+1:]...) 23 return elem 24 } 25 26 func (l *PriorityList) Next() interface{} { 27 return l.remove(l.Len() - 1) 28 } 29 30 var l *PriorityList 31 32 func Foo() { 33 // It would fail here if instrumented code (including inline-label) was copied. 34 for elem := l.Next(); elem != nil; elem = l.Next() { 35 } 36 } 37