2013-08-07 15:03:50 -06:00
|
|
|
// run
|
|
|
|
|
2016-04-10 15:32:26 -06:00
|
|
|
// Copyright 2013 The Go Authors. All rights reserved.
|
2013-08-07 15:03:50 -06:00
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
2013-08-09 16:27:45 -06:00
|
|
|
import "runtime"
|
|
|
|
|
2013-08-07 15:03:50 -06:00
|
|
|
type Closer interface {
|
|
|
|
Close()
|
|
|
|
}
|
|
|
|
|
|
|
|
func nilInterfaceDeferCall() {
|
2013-08-09 16:27:45 -06:00
|
|
|
defer func() {
|
|
|
|
// make sure a traceback happens with jmpdefer on the stack
|
|
|
|
runtime.GC()
|
|
|
|
}()
|
2013-08-07 15:03:50 -06:00
|
|
|
var x Closer
|
|
|
|
defer x.Close()
|
|
|
|
}
|
|
|
|
|
|
|
|
func shouldPanic(f func()) {
|
|
|
|
defer func() {
|
|
|
|
if recover() == nil {
|
|
|
|
panic("did not panic")
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
f()
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
shouldPanic(nilInterfaceDeferCall)
|
|
|
|
}
|