Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error cannot convert type <*main.b> to interface <error> on valid Go code #246

Open
codemicro opened this issue Feb 11, 2022 · 3 comments
Open
Assignees
Labels

Comments

@codemicro
Copy link

When attempting to run the following snippet of Go code in the latest version of gophernotes, v0.7.4, I get the following error:

import "fmt"

type b struct {}
func (*b) Error() string { return "hi" }

func main() {
        var e error
        e = &b{}

        fmt.Println(e)
}
repl.go:8:9: error compiling assignment: e = &b{}
	repl.go:8:9: cannot convert type <*main.b> to interface <error>: missing method  Error

However, running essentially the same snippet with a package main declaration at the top yields the correc output.

package main

import "fmt"

type b struct {}
func (*b) Error() string { return "hi" }

func main() {
        var e error
        e = &b{}

        fmt.Println(e)
}
> go run main.go 
hi

:)

@cosmos72
Copy link
Member

cosmos72 commented Feb 11, 2022

This is really weird:
I can reproduce the issue with gophernotes, but running your snippet in gomacro works as expected.
And they use the same interpreter (I used exactly matching version).

I will try to better examine this issue in the next days

@cosmos72 cosmos72 self-assigned this Aug 14, 2022
@cosmos72 cosmos72 added the bug label Aug 14, 2022
@jgoldschrafe
Copy link

jgoldschrafe commented Dec 21, 2022

Unsure if this is remotely helpful, but I can confirm I'm hitting this issue as well, and able to reproduce it using the snippet above.

  • macOS Monterey
  • Gophernotes 0.7.5
  • Go 1.19.3
  • Python 3.10.5

Jupyter core at the following versions:

Selected Jupyter core packages...
IPython          : 8.6.0
ipykernel        : 6.16.2
ipywidgets       : not installed
jupyter_client   : 7.4.4
jupyter_core     : 4.11.2
jupyter_server   : 1.21.0
jupyterlab       : 3.5.0
nbclient         : 0.7.0
nbconvert        : 7.2.3
nbformat         : 5.7.0
notebook         : 6.5.2
qtconsole        : not installed
traitlets        : 5.5.0

Additionally, I can confirm that any interface methods seem to have difficulty resolving, not just error.

@cosmos72
Copy link
Member

cosmos72 commented Mar 28, 2024

seems to be fixed in @latest version (not yet released with a formal version number)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants