gopherdata / gophernotes

The Go kernel for Jupyter notebooks and nteract.
MIT License
3.8k stars 264 forks source link

internal error: proxy not found for interface type <error> #176

Closed xdays closed 5 years ago

xdays commented 5 years ago

Here's my code:

import (
    "fmt"
    "log"
    "errors"
)

type sqrError struct{
    lat string
    long string
    err error
}

func (se sqrError) Error() string {
    return fmt.Sprintf("math error: %v %v %v", se.lat, se.long, se.err)
}

func test4() {
    _, err := sqrt(-10)
    if err != nil {
        log.Println(err)
    }
}

func sqrt(f float64) (float64, error) {
    if f<0 {
        e := errors.New("more cola needed")
        return 0, sqrError{"50 N", "99 W", e}
    }
    return 42, nil
}
test4()

result is:

repl.go:122:19: internal error: proxy not found for interface type <error>

Here's code from play.golang.org https://play.golang.org/p/gXuiTQmUroW

and result is:

2009/11/10 23:00:00 math error: 50 N 99 W more cola needed

Thanks!

cosmos72 commented 5 years ago

ops, my fault! There's a lot of code to allow interpreted types to implement interfaces, yet somehow I forgot about the humble error. Fixing it.

cosmos72 commented 5 years ago

Fixed in 3f7b312635dffe42fac7ed3cf13e47039735b16e

Please note that log.Println(err) will write to jupyter console, which may not be visible. In order to print to the currently open notebook, use fmt.Println(err)