You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Can't compile a function with no return after panic.
IMHO, adding the 'panic' clause after 'throw' in the following example is a dead code and should be omitted.
package main
import"fmt"functhrow(messagestring){
panic(message)
}
funcfoo(valueint) int{
switchvalue {
case1:
return2case3:
return4
}
throw("Can't do this!")
//panic("Can't do this!") // uncomment this to compile.
}
funcmain() {
fmt.Printf("Hello world: %v", foo(1))
}
expected: code compiles. got: ./test.go:18: missing return at end of function version:
go version go1.5.1 darwin/amd64
go version go1.5.1 windows/amd64