Debian Codegraph @

test/fixedbugs/issue37837.dir/a.go

raw
1 // Copyright 2020 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
5 package a
6
7 func F(i interface{}) int { // ERROR "can inline F" "i does not escape"
8 switch i.(type) {
9 case nil:
10 return 0
11 case int:
12 return 1
13 case float64:
14 return 2
15 default:
16 return 3
17 }
18 }
19
20 func G(i interface{}) interface{} { // ERROR "can inline G" "leaking param: i"
21 switch i := i.(type) {
22 case nil: // ERROR "moved to heap: i"
23 return &i
24 case int: // ERROR "moved to heap: i"
25 return &i
26 case float64: // ERROR "moved to heap: i"
27 return &i
28 case string, []byte: // ERROR "moved to heap: i"
29 return &i
30 default: // ERROR "moved to heap: i"
31 return &i
32 }
33 }