blob: 698f62ac95678b789b4bcff1b21c454e84af60cf [file] [log] [blame]
Keith Randalla97a91d2013-08-07 14:03:50 -07001// run
2
3// Copyright 2013 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
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}