mirror of
https://github.com/hanzoai/yaegi.git
synced 2026-10-01 00:49:47 +00:00
De-optimize a use case to avoid skipping an assign operation with an implicit type assertion at function call return. Fixes #1122.
29 lines
438 B
Go
29 lines
438 B
Go
package main
|
|
|
|
import "fmt"
|
|
|
|
type CustomError string
|
|
|
|
func (s CustomError) Error() string {
|
|
return string(s)
|
|
}
|
|
|
|
func NewCustomError(errorText string) CustomError {
|
|
return CustomError(errorText)
|
|
}
|
|
|
|
func fail() (err error) {
|
|
return NewCustomError("Everything is going wrong!")
|
|
}
|
|
|
|
func main() {
|
|
fmt.Println(fail())
|
|
var myError error
|
|
myError = NewCustomError("ok")
|
|
fmt.Println(myError)
|
|
}
|
|
|
|
// Output:
|
|
// Everything is going wrong!
|
|
// ok
|