1// run
2
3// Copyright 2019 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
7package main
8
9// This used to print 0, because x was incorrectly captured by value.
10
11func f() (x int) {
12	defer func() func() {
13		return func() {
14			println(x)
15		}
16	}()()
17	return 42
18}
19
20func main() {
21	f()
22}
23