blob: 459434892aa1c3508f9359eac984bb6210543af0 [file] [log] [blame]
Keith Randalla97a91d2013-08-07 14:03:50 -07001// run
2
Emmanuel Odeke53fd5222016-04-10 14:32:26 -07003// Copyright 2013 The Go Authors. All rights reserved.
Keith Randalla97a91d2013-08-07 14:03:50 -07004// 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
Keith Randall36f223d2013-08-09 15:27:45 -07009import "runtime"
10
Keith Randalla97a91d2013-08-07 14:03:50 -070011type Closer interface {
12 Close()
13}
14
15func nilInterfaceDeferCall() {
Keith Randall36f223d2013-08-09 15:27:45 -070016 defer func() {
17 // make sure a traceback happens with jmpdefer on the stack
18 runtime.GC()
19 }()
Keith Randalla97a91d2013-08-07 14:03:50 -070020 var x Closer
21 defer x.Close()
22}
23
24func shouldPanic(f func()) {
25 defer func() {
26 if recover() == nil {
27 panic("did not panic")
28 }
29 }()
30 f()
31}
32
33func main() {
34 shouldPanic(nilInterfaceDeferCall)
35}