Make sure auto names don't conflict with function names. Before this CL,
we confused name a.len (the len field of the slice a) with a.len (the function
len declared on a).
Fixes #15961
Change-Id: I14913de697b521fb35db9a1b10ba201f25d552bb
Reviewed-on: https://go-review.googlesource.com/23789
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
var localpkg *Pkg // package being compiled
+var autopkg *Pkg // fake package for allocating auto variables
+
var importpkg *Pkg // package being imported
var itabpkg *Pkg // fake pkg for itab entries
localpkg = mkpkg("")
localpkg.Prefix = "\"\""
+ autopkg = mkpkg("")
+ autopkg.Prefix = "\"\""
// pseudo-package, for scoping
builtinpkg = mkpkg("go.builtin")
// namedAuto returns a new AUTO variable with the given name and type.
func (e *ssaExport) namedAuto(name string, typ ssa.Type) ssa.GCNode {
t := typ.(*Type)
- s := Lookup(name)
+ s := &Sym{Name: name, Pkg: autopkg}
n := Nod(ONAME, nil, nil)
s.Def = n
s.Def.Used = true
--- /dev/null
+// compile
+
+// Copyright 2016 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package y
+
+type symSet []int
+
+//go:noinline
+func (s symSet) len() (r int) {
+ return 0
+}
+
+func f(m map[int]symSet) {
+ var symSet []int
+ for _, x := range symSet {
+ m[x] = nil
+ }
+}