modernc.org/gc@v1.0.1-0.20240304020402-f0dba7c97c2b/testdata/errchk/test/fixedbugs/issue15091.go (about)

     1  // errorcheck -0 -race
     2  
     3  // Copyright 2016 The Go Authors. All rights reserved.
     4  // Use of this source code is governed by a BSD-style
     5  // license that can be found in the LICENSE file.
     6  
     7  package sample
     8  
     9  type Html struct {
    10  	headerIDs map[string]int
    11  }
    12  
    13  // We don't want to see:
    14  //    internal error: (*Html).xyzzy autotmp_3 (type *int) recorded as live on entry, p.Pc=0
    15  // or (now, with the error caught earlier)
    16  //    Treating auto as if it were arg, func (*Html).xyzzy, node ...
    17  // caused by racewalker inserting instrumentation before an OAS where the Ninit
    18  // of the OAS defines part of its right-hand-side. (I.e., the race instrumentation
    19  // references a variable before it is defined.)
    20  func (options *Html) xyzzy(id string) string {
    21  	for count, found := options.headerIDs[id]; found; count, found = options.headerIDs[id] {
    22  		_ = count
    23  	}
    24  	return ""
    25  }