Skip to content

Instantly share code, notes, and snippets.

@elazarl
Created October 7, 2013 21:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elazarl/6875394 to your computer and use it in GitHub Desktop.
Save elazarl/6875394 to your computer and use it in GitHub Desktop.
possible bug in Go's code generation
package bug
type returnPanic struct {
err error
}
func F() (err error) {
defer func() {
if _, ok := recover().(returnPanic); !ok {
panic(err)
}
}()
return nil
}
package bug
import (
"fmt"
"testing"
)
func TestBasicHadoopConf(t *testing.T) {
fmt.Println("1")
F()
// this never happens, maybe parent defer is inlined here?
panic("hoho")
}
/*
~/D/bug ❯❯❯ go test
1
PASS
ok _/home/elazar/Dropbox/bug 0.005s
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment