| 1 |
# Test of -whylive with reflective call |
| 2 |
# (regression test for golang/go#67915). |
| 3 |
|
| 4 |
# The live function is reached via reflection: |
| 5 |
|
| 6 |
deadcode example.com |
| 7 |
want "unreachable func: dead" |
| 8 |
!want "unreachable func: live" |
| 9 |
|
| 10 |
# Reflective calls have Edge.Site=nil, which formerly led to a crash |
| 11 |
# when -whylive would compute its position. Now it has NoPos. |
| 12 |
|
| 13 |
deadcode -whylive=example.com.live example.com |
| 14 |
want " example.com.main" |
| 15 |
want " static@L0006 --> reflect.Value.Call" |
| 16 |
want "dynamic@L0000 --> example.com.live" |
| 17 |
|
| 18 |
-- go.mod -- |
| 19 |
module example.com |
| 20 |
go 1.18 |
| 21 |
|
| 22 |
-- main.go -- |
| 23 |
package main |
| 24 |
|
| 25 |
import "reflect" |
| 26 |
|
| 27 |
func main() { |
| 28 |
reflect.ValueOf(live).Call(nil) |
| 29 |
} |
| 30 |
|
| 31 |
func live() { |
| 32 |
println("hello") |
| 33 |
} |
| 34 |
|
| 35 |
func dead() { |
| 36 |
println("goodbye") |
| 37 |
} |