| 1 |
// run |
| 2 |
|
| 3 |
// Copyright 2022 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 |
// The inliner would erroneously scan the caller function's body for |
| 8 |
// reassignments *before* substituting the inlined function call body, |
| 9 |
// which could cause false positives in deciding when it's safe to |
| 10 |
// transitively inline indirect function calls. |
| 11 |
|
| 12 |
package main |
| 13 |
|
| 14 |
func main() { |
| 15 |
bug1() |
| 16 |
bug2(fail) |
| 17 |
} |
| 18 |
|
| 19 |
func bug1() { |
| 20 |
fn := fail |
| 21 |
fn = pass |
| 22 |
fn() |
| 23 |
} |
| 24 |
|
| 25 |
func bug2(fn func()) { |
| 26 |
fn = pass |
| 27 |
fn() |
| 28 |
} |
| 29 |
|
| 30 |
func pass() {} |
| 31 |
func fail() { panic("FAIL") } |