1// Copyright 2019 The Go Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style 3// license that can be found in the LICENSE file. 4 5package b 6 7import ( 8 "io/ioutil" 9 10 "./a" 11) 12 13var G int 14 15// An inlinable function. To trigger the bug in question this needs 16// to be inlined here within the package and also inlined into some 17// other package that imports it. 18func ReadValues(data []byte) (vals map[string]interface{}, err error) { 19 err = a.Unmarshal(data, &vals) 20 if len(vals) == 0 { 21 vals = map[string]interface{}{} 22 } 23 return 24} 25 26// A local call to the function above, which triggers the "move to heap" 27// of the output param. 28func CallReadValues(filename string) (map[string]interface{}, error) { 29 defer func() { G++ }() 30 data, err := ioutil.ReadFile(filename) 31 if err != nil { 32 return map[string]interface{}{}, err 33 } 34 return ReadValues(data) 35} 36